security: add response headers, escape LIKE wildcards, cap list limit#155
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
security: add response headers, escape LIKE wildcards, cap list limit#155devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Add X-Content-Type-Options, X-Frame-Options, Referrer-Policy, and Permissions-Policy headers to all HTTP responses via a centralized withSecurityHeaders() wrapper in the Bun.serve() fetch handler. - Escape SQL LIKE metacharacters (%, _, \) in the sessions search query parameter to prevent wildcard injection in the admin UI search. - Cap the chat session list limit parameter to [1, 200] to prevent resource exhaustion from unbounded queries. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
What Changed
Three security hardening fixes from a full codebase audit:
Security headers on all HTTP responses (
src/core/server.ts)handleRequest()functionwithSecurityHeaders()that setsX-Content-Type-Options: nosniff,X-Frame-Options: DENY,Referrer-Policy: strict-origin-when-cross-origin, andPermissions-Policy: camera=(), microphone=(), geolocation=()LIKE wildcard escape in sessions search (
src/ui/api/sessions.ts)buildWhere()helper passes user input directly into aLIKE '%...%'pattern%and_metacharacters are now escaped with backslash +ESCAPE '\'clause so search behaves as literal substring matchCap chat session list
limitparameter (src/chat/http.ts)Number(url.searchParams.get("limit")) || 50with no upper bound[1, 200]to prevent resource exhaustionWhy
Addresses findings from a security scan across 7 categories (hardcoded secrets, SQL injection, unvalidated input, insecure dependencies, CORS, debug endpoints, missing auth). The codebase is well-secured overall — parameterized queries, SSRF-safe callback validation, HMAC webhook signatures, bearer+scope MCP auth, cookie auth on UI routes, path traversal defense. These three fixes harden the remaining medium-severity gaps.
How I Tested
Checklist
bun test)bun run lint)bun run typecheck).envfiles includedLink to Devin session: https://app.devin.ai/sessions/538071d859f94ccba624cae67a12ad6b
Requested by: @mcheemaa