security: fix OData injection, path-segment injection, token file perms, error verbosity#3
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
…missions, and error verbosity - Add _sanitize.py to both servers with safe_id(), escape_odata_string(), escape_odata_search() - Validate all user-supplied IDs (message_id, thread_id, draft_id, etc.) against path-traversal chars - Escape OData filter value in outlook_read_thread to prevent filter injection - Strip double-quotes from outlook_search query to prevent $search breakout - Restrict token file permissions to 0o600 (owner-only) in both auth modules - Truncate error response bodies to 200 chars to avoid leaking sensitive API data - Clamp outlook_search top parameter to [1, 1000] 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.
Summary
Fixes 5 security issues found during a full codebase audit:
Critical — OData injection (Outlook server)
outlook_read_threadinterpolatesthread_iddirectly into a$filterclause. A crafted value like' or 1 eq 1 or 'breaks out of the filter and returns arbitrary messages. Similarly,outlook_searchinterpolatesqueryinto$search="…"— an embedded"escapes the phrase.Fix: new
_sanitize.pymodule addsescape_odata_string()(doubles') andescape_odata_search()(strips").Critical — path-segment injection (both servers)
All 20 endpoints interpolate user-supplied IDs into URL paths (
/messages/{message_id}/modify, etc.). A crafted ID containing/or?redirects the HTTP request to an unintended API endpoint.Fix:
safe_id(value, name)validates IDs match^[A-Za-z0-9_\-+=.]+$before interpolation. Added to every tool function that accepts an ID parameter.High — token files world-readable
gmail_token.jsonandoutlook_token.jsonare written viaPath.write_text()inheriting umask (~0o644). Any local user can read refresh tokens.Fix:
TOKEN_PATH.chmod(0o600)after every write.High — verbose error messages
RuntimeError(f"gmail error {status}: {r.text}")returns the full upstream body, which may contain email content or internal error details.Fix: truncate
r.textto 200 chars in bothgmail.pyandgraph.py.Medium — unbounded
topoutlook_searchaccepted arbitrarytopvalues. Now clamped to[1, 1000].Link to Devin session: https://app.devin.ai/sessions/929ae96deee24a03b03b82e2890d3921
Requested by: @fafaisland