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

Adding code with some deep sinks #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.owasp.webgoat.lessons.vulnerablecomponents;

import java.io.File;
import java.io.IOException;
import org.hsqldb.lib.FileUtil;
import org.jsoup.helper.DataUtil;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DSAST {
@PostMapping("/DAST/Spring/delete")
public void springDelete(@RequestParam String input) {

String directory = "./target/directory";
String[] filenames = StringUtils.commaDelimitedListToStringArray(input);
for (String filename : filenames) {
var file = new File(directory, filename);
FileSystemUtils.deleteRecursively(file);

Check failure

Code scanning / SonarCloudsquad-2

I/O function calls should not be vulnerable to path injection attacks High

Change this code to not construct the path from user-controlled data. See more on SonarCloud

Check warning

Code scanning / SonarCloudsquad-2

Accessing files should not lead to filesystem oracle attacks Medium

Change this code to not construct the path from user-controlled data. See more on SonarCloud
}
}

@PostMapping("/DAST/hsqldb/delete")
public void hsqldbDelete(@RequestParam String filename) {

String directory = "./target/directory";
var file = new File(directory, filename);
FileUtil.getFileUtil().delete(filename);

Check failure

Code scanning / SonarCloudsquad-2

I/O function calls should not be vulnerable to path injection attacks High

Change this code to not construct the path from user-controlled data. See more on SonarCloud
}

public void jsoupLoad(@RequestParam String filename) throws IOException {

String directory = "./target/directory";
var file = new File(directory, filename);
DataUtil.load(file, "utf-8", "uri://");

Check failure

Code scanning / SonarCloudsquad-2

I/O function calls should not be vulnerable to path injection attacks High

Change this code to not construct the path from user-controlled data. See more on SonarCloud
}
}