Repository navigation
🔒 fix: use json instead of ast.literal_eval for state data - #12484
undivisible merged 5 commits into
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9406559a16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this — the core change is right, and it brings task_integrations.py in line with the sibling OAuth state handling in routers/integrations.py, which already serializes with json.dumps/json.loads. Two things need fixing before merge:
Blocking
- Stray
pr_body.mdcommitted at the repo root. The failure-class contract is evaluated against the PR description (the preflight pulls it from the GitHub API), never against a file in the diff — so this file doesn't satisfy the check and would land in the repo root on main. Please delete it from the branch and addFailure-Class: noneon its own line in the PR description instead. That's exactly what the failingHygienejob (failure-class-protocol→missing_declaration) is asking for: all three commits havefix:subjects and the current description has no declaration. The next push re-runs Hygiene with both fixes in place. - Stale docstring in
backend/tests/unit/test_task_integrations_oauth_atomic.py— lines 6–7 still read "(This handler parses the stored value with ast.literal_eval, so the fixture stores a Python repr rather than JSON.)". You updated the fixtures tojson.dumps(L109, L120) but not this sentence; it now documents the opposite of the code under test.
Non-blocking observations
backend/routers/task_integrations.pyL112/L278: the round-trip is correct — the only writer (get_oauth_url) storesjson.dumps({'uid', 'app_key', 'created_at'}), all string values, and the callback'sstate_data.get('app_key')/['uid']access behaves identically on the JSON-loaded dict.- Rollout note: states written before deploy hold Python-repr strings; consuming one now raises inside the
tryand returnsNone(invalid_state). Keys expire afterOAUTH_STATE_EXPIRY = 600s, so the blip is bounded to in-flight flows within a ~10-minute window at deploy time. Fine — just worth knowing when this ships. - The sibling
validate_and_consume_oauth_stateinrouters/integrations.pyadditionally guardsisinstance(loaded, dict)before returning; not strictly needed here since this writer only ever stores a dict, but it would be a cheap consistency win.
Requesting changes for the stray file and the stale docstring; the serialization swap itself looks good.
Automated review on behalf of the maintainers. Human sign-off specifically wanted on the OAuth state serialization change in the auth flow before merge.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Approve only: legitimate security hardening (ast.literal_eval->json) but PR Metadata Preflight CI check is failing — hard floor blocks merge.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_2003998c-6a35-4ff2-adeb-6b7abd43cab8) |
|
Addressed Git-on-my-level CRs + Codex P2:
Pushed in f80686a. |
Resolved on f80686a: the stray pr_body.md is gone (diff is now only task_integrations.py and its unit test), the stale ast.literal_eval docstring is corrected, and Failure-Class: none is declared (failure-class-protocol passes). No remaining change requests from this review.
|
Thanks — all three items from the earlier change request are verified fixed on f80686a:
The serialization change itself reads right at the new head: One thing that is not yours: the failing Once that repo-side blocker clears, this just needs a fresh maintainer sign-off on the current head, since the earlier approval predates f80686a's fallback logic. Automated review on behalf of the maintainers. Human sign-off specifically wanted on the current head's OAuth state parse-fallback in the auth flow before merge. by AI on behalf of David — if you need David's attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Genuine CSRF/DoS-hardening fix replacing ast.literal_eval with json.dumps/loads for OAuth state stored in Redis, with backward-compat parsing for legacy single-quote values and updated tests; would score 5/5 on the confidence gate but 'PR Metadata Preflight' and 'Hygiene' required checks are actively failing, which trips the CI hard floor. Approve-only, held from merge on CI.
f80686a to
9103753
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_31a5a7fd-956e-453e-8322-173df5fffe3b) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 910375370a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Pre-migration writers stored str(dict) (single quotes). Those keys | ||
| # expire after OAUTH_STATE_EXPIRY (10 min). Map them to JSON without | ||
| # reintroducing ast.literal_eval. | ||
| state_data = json.loads(raw.replace("'", '"')) |
There was a problem hiding this comment.
Preserve quoted UIDs when parsing legacy state
For an in-flight state whose UID contains a single or double quote, blindly replacing every apostrophe does not produce the JSON encoding of the old Python representation; for example, str({'uid': "o'connor"}).replace("'", '"') raises JSONDecodeError. The authentication layer can return unvalidated UID strings, and because GETDEL has already consumed the record, the affected OAuth callback cannot be retried. Fresh evidence beyond the earlier migration comment is this quoted-UID case; the updated tests exercise only new JSON records and never the compatibility branch, so parse the legacy representation without altering string contents and add a regression case.
AGENTS.md reference: AGENTS.md:L32-L32
Useful? React with 👍 / 👎.
| except json.JSONDecodeError: | ||
| # Pre-migration writers stored str(dict) (single quotes). Those keys | ||
| # expire after OAUTH_STATE_EXPIRY (10 min). Map them to JSON without | ||
| # reintroducing ast.literal_eval. | ||
| state_data = json.loads(raw.replace("'", '"')) |
There was a problem hiding this comment.
Record successful use of the legacy-state fallback
During the rollout window, a callback that reaches this newly added branch switches from failed JSON parsing to a recovered legacy serialization mode, but successful recovery emits no fallback telemetry. Operators therefore cannot determine whether old state records are still being consumed or whether the compatibility path can safely be removed; call the shared record_fallback helper with a recovered outcome after the legacy parse succeeds.
AGENTS.md reference: backend/AGENTS.md:L304-L304
Useful? React with 👍 / 👎.
3aad6f2 to
69348e1
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b75964d4-c7c2-418e-8aac-04378860838d) |
|
Verified on 99d2c4c — the two Sep 5 commits are clean CI repair on top of the security fix, and the previously failing checks ( Security fix (unchanged since f80686a, re-verified at head):
CI-repair commits:
Both maintainer approvals (Sep 1 / Sep 3) predate this head, so keeping by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Failure-Class: none Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Failure-Class: none Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
utils.conversations.merge_conversations imports utils.conversations.projection_payload, which does `from models.client_processing import PROJECTION_FAMILY_FIELDS`. The module-scoped merge fixtures in test_batch_upload_storage.py and test_merge_validation.py stub `models` with an empty __path__, so the real models.client_processing could not be found and every merge-fixture test errored with ModuleNotFoundError on CI (job 101292145767). Same fix as #12776: add models.client_processing to the model_submods dict and, after the stub loop, replace the MagicMock with a real frozenset so strip_client_processing cannot hang iterating a mock. Test-only change; no production code touched. Verified: cd backend && python -m pytest tests/unit/test_batch_upload_storage.py tests/unit/test_merge_validation.py -q --tb=line Before: 24 passed, 43 errors (ModuleNotFoundError: No module named 'models.client_processing') After: 67 passed in 2.49s Failure-Class: none
99d2c4c to
f767a71
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_dec059c0-6599-4cc6-a81a-af1f85c65982) |
|
Verified on the rebased head Security fix (unchanged through the rebase, re-verified at this head):
Test-harness notes (no production behavior):
CI on Non-blocking nit: the legacy fallback's Since the rebase produced new commit SHAs, both earlier approvals predate this head — re-confirmation from a maintainer on by AI on behalf of David |
🎯 What: The vulnerability fixed was the use of
⚠️ Risk: While safer than
ast.literal_evalto parsestate_data_strwhen retrieving OAuth state data from Redis.eval(),ast.literal_evalcan still cause a denial-of-service (crashing the process) if provided deeply nested structures.🛡️ Solution: Changed the serialization of
state_datato usejson.dumpsand deserialization to usejson.loads. Also updated the mockedredispayloads in tests to match the newjson.dumpsformat. In-flight pre-migrationstr(dict)payloads (single quotes, 10-minute TTL) are still accepted by mapping them to JSON.Failure-Class: none
Rebase note (2026-09-07): the branch was rebased onto current
main; the former head commit99d2c4cbca(desktop_manual config sync) was dropped because it was fully superseded by #12788 (e02d56da68, same intent + newer dashboard paths).Verification: rebased-branch unit tests:
70 passed(test_task_integrations_oauth_atomic,test_merge_validation,test_batch_upload_storage).PR created automatically by Jules for task 5719183998940294315 started by @undivisible
Note
Medium Risk
Touches OAuth CSRF state parsing on the task-integrations callback path; behavior change is mostly format-safe with a brittle legacy fallback, so mis-parsed state could reject valid in-flight logins briefly.
Overview
Task integration OAuth CSRF state in Redis is now written with
json.dumpsand read withjson.loads, replacingstr(dict)plusast.literal_eval. That removes a DoS class from maliciously nested literal structures while keeping the existing atomicGETDELconsume path.validate_and_consume_oauth_statealso rejects non-dict payloads and, for a short migration window, still accepts legacy single-quotestr(dict)values by normalizing quotes beforejson.loads(noast).Unit tests were updated: OAuth atomic tests use JSON fixtures; merge/batch upload import stubs set
PROJECTION_FAMILY_FIELDSon the mockedmodels.client_processingmodule.Reviewed by Cursor Bugbot for commit f767a71. Configure here.
Product invariants affected