Repository navigation
Fix 13 CodeQL security alerts - #68
Merged
Merged
Conversation
agent-api.py: - Add _safe_id() to sanitize task IDs against path traversal (#2-4, #8) - Reject path traversal in /media/ before resolve (#5-7) - Sanitize mime type to prevent HTTP response splitting (#1) inline-tools.ts: - Escape backslashes in shell args for openUrl and switchApp (#9-11) conversation-server.ts: - Mask phone number in startup log (#12) - Escape meetingId/passcode in TwiML Play digits (#13) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sonichi
approved these changes
Mar 31, 2026
sonichi
left a comment
Owner
There was a problem hiding this comment.
Thorough security hardening — all fixes are correct and introduce no regressions.
Reviewed each fix:
_safe_id(): Properly strips path traversal chars. Real task IDs (task-*,answer-*,proactive-*) all pass through unchanged./media/pre-check: Good belt-and-suspenders on top of existingis_relative_to.- MIME sanitization: Prevents header injection via crafted filenames.
- Shell escaping order fix: Backslashes before quotes — correct.
- TwiML XML escaping: Prevents meeting ID injection into
<Play>. - Phone number masking: Standard PII handling.
Two minor suggestions:
- Consider adding
cleaned.replace('..', '')to_safe_idfor extra hardening, even though..isn't exploitable in current usage. - The test file mentioned in the description isn't in the diff — consider committing it.
Ship it.
1 of 2 tasks
liususan091219
added a commit
to liususan091219/sutando-fork
that referenced
this pull request
May 28, 2026
* Fix 13 CodeQL security alerts agent-api.py: - Add _safe_id() to sanitize task IDs against path traversal (sonichi#2-4, sonichi#8) - Reject path traversal in /media/ before resolve (sonichi#5-7) - Sanitize mime type to prevent HTTP response splitting (sonichi#1) inline-tools.ts: - Escape backslashes in shell args for openUrl and switchApp (sonichi#9-11) conversation-server.ts: - Mask phone number in startup log (sonichi#12) - Escape meetingId/passcode in TwiML Play digits (sonichi#13) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add security comments to shell escaping in inline-tools Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- 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
Path traversal prevention (agent-api.py)
Task IDs and media paths from HTTP requests were used directly in file operations without sanitization. A malicious request like
GET /result/../../.envcould read arbitrary files outside the intended directory._safe_id()that strips all characters except alphanumeric, dash, underscore, dot..and absolute paths in/media/endpoint before resolvingShell injection prevention (inline-tools.ts)
The
openUrlandswitchApptools pass user input toosascriptvia shell. Backslashes were not escaped, allowing crafted input to break out of the quoted string and execute arbitrary shell commands.Sensitive data exposure (conversation-server.ts)
The Twilio phone number was logged in cleartext at startup, visible in log files.
XML injection in TwiML (conversation-server.ts)
Meeting IDs and passcodes were interpolated raw into TwiML
<Play digits>XML without escaping, allowing XML injection via crafted meeting IDs.esc()XML escaping to Play digits attributeTest plan
python3 tests/security-sanitization.test.py— 17 assertions passinggh api repos/sonichi/sutando/code-scanning/alerts --jq '[.[] | select(.state == "open")] | length'🤖 Generated with Claude Code