security: fix 6 vulnerabilities (XSS, CSRF, SSRF, path traversal, credentials, prompt injection)#195
Merged
zfoong merged 13 commits intoCraftOS-dev:V1.2.3from Apr 15, 2026
Conversation
Fixed the service. Uninstall issue.
…dential storage, prompt injection) - Fix reflected XSS in OAuth callback by HTML-escaping error parameter - Add OAuth state parameter validation to prevent CSRF attacks - Add SSRF protection to http_request action (block private IPs, cloud metadata) - Add path traversal protection to read_file/write_file actions (block sensitive dirs) - Set restrictive file permissions (0600) on stored credentials - Make prompt sanitizer actually strip detected injection patterns instead of just logging Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
zfoong
reviewed
Apr 15, 2026
Collaborator
zfoong
left a comment
There was a problem hiding this comment.
SSRF check implementation issue
- The SSRF validation appears to use the wrong module reference in the exception handling. It catches “socket.gaierror”, but the socket module is imported as “_socket”. This could raise a NameError.
Sanitizer logic may break legitimate usage
- The change from logging to stripping content might produce incorrect outputs. Since pattern matching with words might be too broad.
Path traversal protection design
- Same as above.
Undo changes for write_file action
Undo changes on read_file
undo changes on prompt_sanitizer
4 tasks
eesb99
added a commit
to eesb99/CraftBot
that referenced
this pull request
Apr 15, 2026
- context/claude.md: Session 2 summary with unified review findings, implementation details, code design assessment, and advisor recommendations - Updated PR references (CraftOS-dev#195 merged, CraftOS-dev#198 open) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 tasks
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
Security review of the codebase identified 12 vulnerabilities. This PR fixes the 6 that can be cleanly patched without architectural changes:
oauth_server.pyto prevent script injection via crafted callback URLsstateparameter in the OAuth callback to prevent cross-site request forgery10.x,172.16.x,192.168.x,127.x) and cloud metadata endpoints (169.254.169.254).credentials,.ssh,.gnupg,.aws)0600(owner read/write only) on credential files and0700on the.credentialsdirectory[FILTERED]Remaining issues (not addressed here — require design decisions)
These should be tracked as separate issues:
embedded_credentials.py(base64 is not encryption)run_python.pyusesexec()without sandboxing in same processrun_shell.pyallows unrestrictedshell=TrueexecutionModuleNotFoundErrorFiles changed
agent_core/core/credentials/oauth_server.py— XSS fix + CSRF state validationapp/data/action/http_request.py— SSRF protectionapp/data/action/read_file.py— Path traversal protectionapp/data/action/write_file.py— Path traversal protectionapp/external_comms/credentials.py— File permission hardeningapp/security/prompt_sanitizer.py— Enforce pattern strippingTest plan
read_filecan still read workspace files but blocks.ssh/pathswrite_filecan still create files in workspace but blocks.credentials/pathshttp_requestcan reach external APIs but blocks169.254.169.2540600permissions on Linux/macOS🤖 Generated with Claude Code