Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Security Finding: Path/Directory Traversal (CWE-22, High Severity) in UnrestrictedExtensionUploadServlet.java:110 #76

Open
2 tasks
joshn-whitesource-app bot opened this issue Feb 7, 2024 · 0 comments
Labels
Mend: code security findings Code security findings detected by Mend

Comments

@joshn-whitesource-app
Copy link
Contributor

joshn-whitesource-app bot commented Feb 7, 2024

Code Security Finding

This finding was first detected on 2023-12-06 01:34pm GMT and is still present in the last scan performed on 2024-02-15 10:26pm GMT:

SeverityVulnerability TypeCWEFileData Flows
HighPath/Directory Traversal

CWE-22

UnrestrictedExtensionUploadServlet.java:110

1
Vulnerable Code

// Convert color image into gray scale image.
private boolean convert2GrayScale(String fileName) throws IOException {
boolean isConverted = false;
try {
// Convert the file into gray scale image.
BufferedImage image = ImageIO.read(new File(fileName));

1 Data Flow/s detected

String fileName = MultiPartFileUtils.getFileName(filePart);

public static String getFileName(final Part part) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

for (String content : part.getHeader("content-disposition").split(";")) {

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");

String fileName = MultiPartFileUtils.getFileName(filePart);

isConverted = convert2GrayScale(new File(savePath + File.separator + fileName).getAbsolutePath());

isConverted = convert2GrayScale(new File(savePath + File.separator + fileName).getAbsolutePath());

isConverted = convert2GrayScale(new File(savePath + File.separator + fileName).getAbsolutePath());

isConverted = convert2GrayScale(new File(savePath + File.separator + fileName).getAbsolutePath());

isConverted = convert2GrayScale(new File(savePath + File.separator + fileName).getAbsolutePath());

isConverted = convert2GrayScale(new File(savePath + File.separator + fileName).getAbsolutePath());

private boolean convert2GrayScale(String fileName) throws IOException {

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Path/Directory Traversal Training

● Videos

   ▪ Secure Code Warrior Path/Directory Traversal Video

● Further Reading

   ▪ OWASP Path Traversal

   ▪ OWASP Input Validation Cheat Sheet

🏴 Suppress Finding
  • ... as False Alarm
  • ... as Acceptable Risk
@joshn-whitesource-app joshn-whitesource-app bot added the Mend: code security findings Code security findings detected by Mend label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mend: code security findings Code security findings detected by Mend
Projects
None yet
Development

No branches or pull requests

0 participants