ci(l1): loop HTML comment removal to prevent incomplete sanitization#6322
Conversation
Fixes CodeQL alert #119 (js/incomplete-multi-character-sanitization).
🤖 Kimi Code ReviewReview of
|
🤖 Claude Code ReviewThe diff is small and self-contained. I have enough context to write the review. PR Review:
|
🤖 Codex Code ReviewNo blocking findings in this PR.
Optional improvement:
Automated review by OpenAI Codex · custom prompt |
Greptile SummaryThis PR hardens the
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| .github/scripts/set-pr-status.js | Replaces single-pass HTML comment removal with a stable do-while loop to prevent incomplete multi-character sanitization; the rest of the file is unchanged. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([Start: prBody]) --> B[withoutComments = body]
B --> C[previous = withoutComments]
C --> D["withoutComments = withoutComments\n.replace(/<!--[\s\S]*?-->/g, '')"]
D --> E{withoutComments\n=== previous?}
E -- No, matches found --> C
E -- Yes, stable --> F["matchAll closes/fixes/resolves #N"]
F --> G([Return issue numbers])
Last reviewed commit: f737859
The loop always terminates: each iteration either removes at least one
The loop-until-stable approach is the one recommended by CodeQL's own documentation for this exact alert type. It's also easier to reason about correctness compared to a more complex single-pass regex. |
…ambdaclass#6322) ## Summary Fixes [CodeQL alert lambdaclass#119](https://github.com/lambdaclass/ethrex/security/code-scanning/119) (`js/incomplete-multi-character-sanitization`). ### Problem In `.github/scripts/set-pr-status.js`, `extractLinkedIssueNumbers` strips HTML comments from PR bodies before extracting "closes #N" keywords. The regex used a single-pass replacement: ```js const withoutComments = body.replace(/<!--[\s\S]*?-->/g, ""); ``` A single-pass replacement of `<!--...-->` can leave behind a valid HTML comment if the input is crafted so that removing one match creates a new one. For example, input `<!-<!-- foo -->->` would produce `<!-- foo -->` after one pass. This means a malicious PR author could hide closing keywords inside crafted comment nesting to manipulate project board status. The practical risk is low (CI context, trusted-ish input), but the fix is trivial. ### Fix Replace the single-pass `.replace()` with a loop that repeats until stable: ```js let withoutComments = body; let previous; do { previous = withoutComments; withoutComments = withoutComments.replace(/<!--[\s\S]*?-->/g, ""); } while (withoutComments !== previous); ``` This is the approach recommended by [CodeQL's own documentation](https://codeql.github.com/codeql-query-help/javascript/js-incomplete-multi-character-sanitization/) for this exact alert type. ## Test plan - No behavioral change for normal PR bodies — the single pass already removes all comments; the loop just adds a no-op second iteration confirming stability - Edge case: nested/overlapping comment markers like `<!-<!-- foo -->->` are now fully stripped across multiple iterations - Resolves CodeQL alert `js/incomplete-multi-character-sanitization`
…6322) ## Summary Fixes [CodeQL alert #119](https://github.com/lambdaclass/ethrex/security/code-scanning/119) (`js/incomplete-multi-character-sanitization`). ### Problem In `.github/scripts/set-pr-status.js`, `extractLinkedIssueNumbers` strips HTML comments from PR bodies before extracting "closes #N" keywords. The regex used a single-pass replacement: ```js const withoutComments = body.replace(/<!--[\s\S]*?-->/g, ""); ``` A single-pass replacement of `<!--...-->` can leave behind a valid HTML comment if the input is crafted so that removing one match creates a new one. For example, input `<!-<!-- foo -->->` would produce `<!-- foo -->` after one pass. This means a malicious PR author could hide closing keywords inside crafted comment nesting to manipulate project board status. The practical risk is low (CI context, trusted-ish input), but the fix is trivial. ### Fix Replace the single-pass `.replace()` with a loop that repeats until stable: ```js let withoutComments = body; let previous; do { previous = withoutComments; withoutComments = withoutComments.replace(/<!--[\s\S]*?-->/g, ""); } while (withoutComments !== previous); ``` This is the approach recommended by [CodeQL's own documentation](https://codeql.github.com/codeql-query-help/javascript/js-incomplete-multi-character-sanitization/) for this exact alert type. ## Test plan - No behavioral change for normal PR bodies — the single pass already removes all comments; the loop just adds a no-op second iteration confirming stability - Edge case: nested/overlapping comment markers like `<!-<!-- foo -->->` are now fully stripped across multiple iterations - Resolves CodeQL alert `js/incomplete-multi-character-sanitization`
…ambdaclass#6322) ## Summary Fixes [CodeQL alert lambdaclass#119](https://github.com/lambdaclass/ethrex/security/code-scanning/119) (`js/incomplete-multi-character-sanitization`). ### Problem In `.github/scripts/set-pr-status.js`, `extractLinkedIssueNumbers` strips HTML comments from PR bodies before extracting "closes #N" keywords. The regex used a single-pass replacement: ```js const withoutComments = body.replace(/<!--[\s\S]*?-->/g, ""); ``` A single-pass replacement of `<!--...-->` can leave behind a valid HTML comment if the input is crafted so that removing one match creates a new one. For example, input `<!-<!-- foo -->->` would produce `<!-- foo -->` after one pass. This means a malicious PR author could hide closing keywords inside crafted comment nesting to manipulate project board status. The practical risk is low (CI context, trusted-ish input), but the fix is trivial. ### Fix Replace the single-pass `.replace()` with a loop that repeats until stable: ```js let withoutComments = body; let previous; do { previous = withoutComments; withoutComments = withoutComments.replace(/<!--[\s\S]*?-->/g, ""); } while (withoutComments !== previous); ``` This is the approach recommended by [CodeQL's own documentation](https://codeql.github.com/codeql-query-help/javascript/js-incomplete-multi-character-sanitization/) for this exact alert type. ## Test plan - No behavioral change for normal PR bodies — the single pass already removes all comments; the loop just adds a no-op second iteration confirming stability - Edge case: nested/overlapping comment markers like `<!-<!-- foo -->->` are now fully stripped across multiple iterations - Resolves CodeQL alert `js/incomplete-multi-character-sanitization`
Prior commit (2496c2b) trimmed `test/tests/levm/eip7708_tests.rs` to a single constants check, on the assumption the file was fully new in this PR. It wasn't — 25 of the 28 tests had been on `main` for a while (landed in PR #6322, well before this branch diverged). Only 3 tests were genuinely added on this PR: - test_burn_logs_emitted_in_lex_ascending_order_three_accounts - test_coinbase_priority_fee_does_not_emit_transfer_log - test_multi_selfdestruct_dest_emits_single_burn_log_with_combined_balance Those three are covered by the EELS burn/transfer-logs ef-tests we now run via the blockchain runner, so dropping them is correct. The other 25 belong to main and should not have been touched here. Restored to main verbatim and added the new `Environment::is_system_call` field introduced by this PR.
Summary
Fixes CodeQL alert #119 (
js/incomplete-multi-character-sanitization).Problem
In
.github/scripts/set-pr-status.js,extractLinkedIssueNumbersstrips HTML comments from PR bodies before extracting "closes #N" keywords. The regex used a single-pass replacement:A single-pass replacement of
<!--...-->can leave behind a valid HTML comment if the input is crafted so that removing one match creates a new one. For example, input<!-<!-- foo -->->would produce<!-- foo -->after one pass.This means a malicious PR author could hide closing keywords inside crafted comment nesting to manipulate project board status. The practical risk is low (CI context, trusted-ish input), but the fix is trivial.
Fix
Replace the single-pass
.replace()with a loop that repeats until stable:This is the approach recommended by CodeQL's own documentation for this exact alert type.
Test plan
<!-<!-- foo -->->are now fully stripped across multiple iterationsjs/incomplete-multi-character-sanitization