Repository navigation
Fix remaining CodeQL security alerts (round 2) - #69
Merged
Merged
Conversation
agent-api.py: - Add _safe_path() with resolve() + is_relative_to() for all file access - Replace mimetypes.guess_type with fixed SAFE_TYPES allowlist - Sanitize media path with strict character allowlist - Add resolve + is_relative_to guard on answer task file conversation-server.ts: - Replace regex phone masking with simple slice (CodeQL-friendly) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sonichi
approved these changes
Apr 1, 2026
sonichi
left a comment
Owner
There was a problem hiding this comment.
LGTM — solid security hardening.
Reviewed each change:
_safe_path(): correct defense-in-depth (sanitize + resolve + is_relative_to). Minor: docstring says returns None but type hint is Path (cosmetic).SAFE_TYPESmime allowlist: reasonable coverage, eliminates response splitting. Note: .html/.js/.svg could be XSS vectors if repo contains attacker-influenced files — low risk for local agent.- Media endpoint: null byte rejection + strict character allowlist + no silent mutation. Solid.
- Answer task file write: now validates resolved path stays within tasks/. Good.
- conversation-server.ts: handles undefined TWILIO_PHONE_NUMBER gracefully.
No regressions. Ship it.
liususan091219
added a commit
to liususan091219/sutando-fork
that referenced
this pull request
May 28, 2026
agent-api.py: - Add _safe_path() with resolve() + is_relative_to() for all file access - Replace mimetypes.guess_type with fixed SAFE_TYPES allowlist - Sanitize media path with strict character allowlist - Add resolve + is_relative_to guard on answer task file conversation-server.ts: - Replace regex phone masking with simple slice (CodeQL-friendly) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the 10 CodeQL alerts that remained after PR #68.
Path traversal (agent-api.py) — alerts #2-7, #14
_safe_path()helper that combines_safe_id()sanitization withresolve()+is_relative_to()validation_safe_path()instead of constructing paths directly from user inputmimetypes.guess_type()with a fixedSAFE_TYPESallowlist (eliminates HTTP response splitting vector)[a-zA-Z0-9_./-]) before resolvingHTTP response splitting (agent-api.py) — alert #1
Clear-text logging (conversation-server.ts) — alert #15
***+ last 4 digits (CodeQL-friendly)Reflected XSS (conversation-server.ts) — alert #13
twimlResponse()sends XML to Twilio's server, not a browser. All interpolated values already useesc()for XML escaping. May need CodeQL suppression comment if alert persists.Test plan
python3 -c "import py_compile; py_compile.compile('src/agent-api.py', doraise=True)"— syntax check passesgh api repos/sonichi/sutando/code-scanning/alerts --jq '[.[] | select(.state == "open")] | length'🤖 Generated with Claude Code