Skip to content

Fix SQL injection, RCE assessed in CI Sense. #9

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
WEB_APP_ADDRESS: https://app.code-intelligence.com
# Directory in which the repository will be cloned.
CHECKOUT_DIR: checkout-dir/
CIFUZZ_DOWNLOAD_URL: "https://github.com/CodeIntelligenceTesting/cifuzz/releases/latest/download/cifuzz_installer_linux_amd64"
CIFUZZ_DOWNLOAD_URL: "https://github.com/CodeIntelligenceTesting/cifuzz/releases/download/v2.18.0/cifuzz_installer_linux_amd64"
CIFUZZ_INSTALL_DIR: ./cifuzz
FUZZING_ARTIFACT: fuzzing-artifact.tar.gz
jobs:
Expand All @@ -42,7 +42,7 @@ jobs:
cd $CHECKOUT_DIR/
$GITHUB_WORKSPACE/$CIFUZZ_INSTALL_DIR/bin/cifuzz bundle \
--commit $GITHUB_SHA \
--branch $GITHUB_REF_NAME \
--branch $GITHUB_HEAD_REF \
--output $GITHUB_WORKSPACE/$CHECKOUT_DIR/$FUZZING_ARTIFACT
shell: "bash"
- id: start-fuzzing
Expand Down
1 change: 1 addition & 0 deletions cifuzz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
## See https://llvm.org/docs/LibFuzzer.html#options
engine-args:
- --instrumentation_includes=com.example.**
- -rss_limit_mb=8192

## Maximum time to run fuzz tests. The default is to run indefinitely.
#timeout: 30m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.web.bind.annotation.RestController;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

@RestController
Expand All @@ -16,11 +17,13 @@ public String greet(@RequestParam(required = false, defaultValue = "World") Stri
try {
Connection conn = getDBConnection();
if (conn != null) {
String query = String.format("INSERT INTO users (name) VALUES ('%s')", name);
conn.createStatement().execute(query);
PreparedStatement stmt = conn.prepareStatement("INSERT INTO users (name) VALUES (?)");
stmt.setString(1, name);
stmt.executeUpdate();
conn.close();
}
} catch (SQLException ignored) {}
} catch (SQLException ignored) {
}
}

return "Greetings " + name + "!";
Expand Down