Skip to content

Security/codeql alert fixes#149

Open
josephismikhail wants to merge 7 commits intomainfrom
security/codeql-alert-fixes
Open

Security/codeql alert fixes#149
josephismikhail wants to merge 7 commits intomainfrom
security/codeql-alert-fixes

Conversation

@josephismikhail
Copy link
Copy Markdown
Contributor

Summary

Fixes all 5 open CodeQL security alerts on main. Three high-severity ReDoS vulnerabilities in the SQL/YAML/Dockerfile parsers, and two medium-severity missing permissions blocks in GitHub Actions workflows.

Type

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Test
  • CI

Changes

Validation

CodeQL flagged these as polynomial-time regex (CWE-1333, CWE-400, CWE-730) and missing least-privilege permissions (CWE-275). Each fix was verified to be behaviorally equivalent to the original.

Checklist

  • Tests pass
  • Smoke tests pass
  • No raw errors introduced
  • CLI output follows Ix format

jsmikhai and others added 5 commits April 5, 2026 17:17
Replaces backtracking-prone /\/\*[\s\S]*?\*\// with Friedl's unrolled
loop pattern to eliminate ReDoS risk on unterminated block comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
)

/\s+$/ can backtrack catastrophically on lines with many spaces.
Replaced with String.trimEnd() which is built-in and regex-free.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
#3)

(?:\s*.*)?$ causes backtracking ambiguity since both \s* and .* match
spaces. Simplified to .*$ which is equivalent and linear-time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
#2)

Workflow uses a GitHub App token exclusively; GITHUB_TOKEN is never
referenced. Adding permissions: {} enforces least privilege.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
#1)

Only contents: read is needed for actions/checkout. Explicit permissions
block enforces least privilege on the GITHUB_TOKEN.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…odeQL #5)

Previous unrolled loop pattern still had ambiguous quantifiers. Replaced
with (?:[^*]|\*[^/])* where alternatives are mutually exclusive, making
backtracking impossible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Regex-based approaches are flagged by CodeQL due to O(n^2) backtracking
when the pattern fails to match. indexOf is a plain linear scan with no
NFA and no backtracking possible.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants