Skip to content

[DO NOT MERGE] verify Semgrep gate blocks merge queue (private-issues#630)#36143

Closed
mbiuki wants to merge 9 commits into
mainfrom
issue-630-semgrep-gate-verify
Closed

[DO NOT MERGE] verify Semgrep gate blocks merge queue (private-issues#630)#36143
mbiuki wants to merge 9 commits into
mainfrom
issue-630-semgrep-gate-verify

Conversation

@mbiuki

@mbiuki mbiuki commented Jun 12, 2026

Copy link
Copy Markdown
Member

Temporary draft — do not merge, will be closed and branch deleted.
checking...
End-to-end verification for dotCMS/private-issues#630. Adds a Java file with deliberate blocking Semgrep findings (SQL injection + command injection) to prove that a red Semgrep fails Finalize / Final Status and blocks merge-queue entry.

Expected: PR Semgrep job FAILS → Finalize / Final Status FAILS. Once observed, this PR is closed and the branch deleted.

🤖 Generated with Claude Code

This PR fixes: #36148

…sues#630)

DO NOT MERGE — temporary fixture proving a red Semgrep fails
Finalize / Final Status and blocks merge-queue entry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the Area : Backend PR changes Java/Maven backend code label Jun 12, 2026
@mbiuki mbiuki self-assigned this Jun 12, 2026
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @mbiuki's task in 51s —— View job


Rollback Safety Analysis

  • Read rollback-unsafe categories reference
  • Get the full PR diff
  • Analyze diff against unsafe categories
  • Apply appropriate label

Result: ✅ Safe To Rollback

The diff introduces a single new Java file (dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java) with no changes to any unsafe category:

Category Assessment
Database migrations (runonce tasks) None
Elasticsearch mapping changes None
Data model changes (contentlet_as_json) None
DROP TABLE / DROP COLUMN None
REST / GraphQL API contract changes None
OSGi interface changes None
VTL viewtool contract changes None

This is a temporary test fixture added purely to trigger Semgrep findings. Rolling back to the previous release leaves no persistent side effects — no schema changes, no data transformations, no index modifications. The label "AI: Safe To Rollback" has been applied.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🤖 Codex Review — openai.gpt-5.5

**[> [🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:21 — SQL is built by concatenating userInput directly into the query, creating SQL injection risk. dotCMS DB access must use parameter binding such as DotConnect.addParam() / prepared parameters.

**[> [🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:21 — SQL is built by concatenating userInput directly into the query, creating SQL injection risk. dotCMS DB access must use parameter binding such as DotConnect.addParam() / prepared parameters.

[🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:25userInput is passed into Runtime.getRuntime().exec("sh -c " + userInput), allowing OS command injection from untrusted input.

**[> [🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:21 — SQL is built by concatenating userInput directly into the query, creating SQL injection risk. dotCMS DB access must use parameter binding such as DotConnect.addParam() / prepared parameters.

[🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:25userInput is passed into Runtime.getRuntime().exec("sh -c " + userInput), allowing OS command injection from untrusted input.

[🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:30 — SQL is again built by concatenating userInput directly into the query, creating SQL injection risk. dotCMS DB access must use parameter binding such as DotConnect.addParam() / prepared parameters.

**[> [🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:21 — SQL is built by concatenating userInput directly into the query, creating SQL injection risk. dotCMS DB access must use parameter binding such as DotConnect.addParam() / prepared parameters.

[🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:25userInput is passed into Runtime.getRuntime().exec("sh -c " + userInput), allowing OS command injection from untrusted input.

[🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:30 — SQL is again built by concatenating userInput directly into the query, creating SQL injection risk. dotCMS DB access must use parameter binding such as DotConnect.addParam() / prepared parameters.

[🔴 Critical] dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java:34userInput is again passed into Runtime.getRuntime().exec("sh -c " + userInput), allowing OS command injection from untrusted input.


Run: #27436315207 · tokens: in: 825 · out: 437 (reasoning: 169) · total: 1262

@mbiuki mbiuki moved this to In Progress in dotCMS - Product Planning Jun 12, 2026
@mbiuki mbiuki added OKR : Security & Privacy Owned by Mehdi dotCMS : Security Team : Security Issues related to security and privacy labels Jun 12, 2026
Comment thread dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java
Comment thread dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java
@semgrep-code-dotcms-test

Copy link
Copy Markdown
Contributor

Semgrep found 1 CUSTOM_INJECTION-2 finding:

  • dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java

The method identified is susceptible to injection. The input should be validated and properly
escaped.

If this is a critical or high severity finding, please also link this issue in the #security channel in Slack.

@mbiuki mbiuki marked this pull request as ready for review June 12, 2026 17:52
this is for test and discussion we are having right now to check the change made in the CUSTOM_INJECTION-1 from semgrep from comment mode to block mode to see if this is effective i.e. it is going to blocke this PR from merging

public ResultSet lookup_1B(final Connection conn, final String userInput) throws SQLException {
final Statement st = conn.createStatement();
return st.executeQuery("SELECT * FROM users WHERE name = '" + userInput + "'");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep identified an issue, but thinks it may be safe to ignore.
The method identified is susceptible to injection. The input should be validated and properly
escaped.

Why this might be safe to ignore:

This is a deliberate security test fixture meant to trigger Semgrep and block CI, not production code. The SQL is intentionally vulnerable, but fixing it would not improve real application security because the file is temporary and marked do not merge.

To resolve this comment:

🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by CUSTOM_INJECTION-2.

If this is a critical or high severity finding, please also link this issue in the #security channel in Slack.

You can view more details about this finding in the Semgrep AppSec Platform.


public ResultSet lookup_1B(final Connection conn, final String userInput) throws SQLException {
final Statement st = conn.createStatement();
return st.executeQuery("SELECT * FROM users WHERE name = '" + userInput + "'");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep identified an issue, but thinks it may be safe to ignore.
SQL Injection is a critical vulnerability that can lead to data or system compromise. By
dynamically generating SQL query strings, user input may be able to influence the logic of
the SQL statement. This could lead to an adversary accessing information they should
not have access to, or in some circumstances, being able to execute OS functionality or code.

Replace all dynamically generated SQL queries with parameterized queries. In situations where
dynamic queries must be created, never use direct user input, but instead use a map or
dictionary of valid values and resolve them using a user-supplied key.

For example, some database drivers do not allow parameterized queries for > or < comparison
operators. In these cases, do not use a user supplied > or < value, but rather have the
user
supply a gt or lt value. The alphabetical values are then used to look up the > and <
values to be used in the construction of the dynamic query. The same goes for other queries
where
column or table names are required but cannot be parameterized.

Example using PreparedStatement queries:

// Some userInput
String userInput = "someUserInput";
// Your connection string
String url = "...";
// Get a connection from the DB via the DriverManager
Connection conn = DriverManager.getConnection(url);
// Create a prepared statement
PreparedStatement st = conn.prepareStatement("SELECT name FROM table where name=?");
// Set each parameters value by the index (starting from 1)
st.setString(1, userInput);
// Execute query and get the result set
ResultSet rs = st.executeQuery();
// Iterate over results
while (rs.next()) {
    // Get result for this row at the provided column number (starting from 1)
    String result = rs.getString(1);
    // ...
}
// Close the ResultSet
rs.close();
// Close the PreparedStatement
st.close();

For more information on SQL Injection see OWASP:
https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html

Why this might be safe to ignore:

This is a temporary verification fixture that explicitly says it deliberately contains blocking Semgrep findings and should not be merged. The match is intentional test code for CI gate validation rather than production logic, so fixing it does not improve real application security.

To resolve this comment:

🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by CUSTOM_INJECTION-1.

If this is a critical or high severity finding, please also link this issue in the #security channel in Slack.

You can view more details about this finding in the Semgrep AppSec Platform.

@semgrep-code-dotcms-test

Copy link
Copy Markdown
Contributor

Semgrep found 1 CUSTOM_INJECTION-2 finding:

  • dotCMS/src/main/java/com/dotcms/SemgrepGateVerification630.java

The method identified is susceptible to injection. The input should be validated and properly
escaped.

If this is a critical or high severity finding, please also link this issue in the #security channel in Slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code dotCMS : Security OKR : Security & Privacy Owned by Mehdi Team : Security Issues related to security and privacy

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

FAKE -- for testing only -- verify Semgrep gate blocks merge queue (private-issues#630)

2 participants