Repository navigation
fix(notion-app): percent-encode reflected uid in OAuth links and redirects - #20400
kaleidoscopeAI wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 4/5
- In
plugins/omi-notion-app/main.py, a truthy non-stringerroris ignored, so a call with validcodeandstatecan still proceed to token exchange instead of failing closed. Reject non-string errors before handling string errors.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/omi-notion-app/main.py">
<violation number="1" location="plugins/omi-notion-app/main.py:1179">
P2: A truthy non-string `error` is silently ignored, so a direct call with valid `code` and `state` continues into token exchange instead of failing closed. Reject non-string errors before handling a string error.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ): | ||
| """Handle Notion OAuth2 callback.""" | ||
| if error: | ||
| if error and isinstance(error, str): |
There was a problem hiding this comment.
P2: A truthy non-string error is silently ignored, so a direct call with valid code and state continues into token exchange instead of failing closed. Reject non-string errors before handling a string error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At plugins/omi-notion-app/main.py, line 1179:
<comment>A truthy non-string `error` is silently ignored, so a direct call with valid `code` and `state` continues into token exchange instead of failing closed. Reject non-string errors before handling a string error.</comment>
<file context>
@@ -1170,27 +1171,28 @@ async def notion_auth(uid: str = Query(...)):
):
"""Handle Notion OAuth2 callback."""
- if error:
+ if error and isinstance(error, str):
+ safe_error = html.escape(error, quote=True)
return HTMLResponse(content=f"""
</file context>
| if error and isinstance(error, str): | |
| if error is not None and not isinstance(error, str): | |
| return HTMLResponse(content="Invalid error parameter", status_code=400) | |
| if error: |
|
CI is green on this head — ready to merge. Head: Fix (plugins/omi-notion-app/main.py): percent-encode the reflected uid at every outbound-URL interpolation — connect link ( Tests (plugins/omi-notion-app/test_notion_security.py): 8 hermetic tests (framework doubles injected via Registered in 5 bounty for #15011. |
|
Reviewed all three changed files at head plugins/omi-notion-app/main.py — The encode-then-escape ordering is correct and applied consistently at every interpolation site: plugins/omi-notion-app/test_notion_security.py — Genuinely hermetic rewrite; the attribute-breakout assertion ( .github/checks-manifest.yaml — Since this modifies the OAuth callback and redirect surface, it needs maintainer sign-off before merge — leaving for human maintainer review rather than an automated approval. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @kaleidoscopeAI — clean, well-scoped hardening follow-up to #15011, and the fresh rebase off main is appreciated. I verified the diff file by file and ran the new suite locally (hermetic, stdlib-only): 8/8 pass. plugins/omi-notion-app/main.py
plugins/omi-notion-app/test_notion_security.py
.github/checks-manifest.yaml
Non-blocking nit: the test file is missing a trailing newline. This touches the OAuth callback surface, so it stays under security-review for maintainer sign-off before merge — the code itself looks correct to me. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
The callback previously only handled string errors (`if error and isinstance(error, str)`), so a truthy non-string `error` was silently ignored and the request flowed on into token exchange when code/state were present. Treat any truthy error as terminal, escaping it when it is a string and returning a generic 400 otherwise. Also add regression coverage for the non-string case and for workspace-name escaping, backing the manifest's stated coverage.
|
Follow-up on the new head 2249870: the incremental commit addresses both non-blocking nits from the earlier review and hardens one more edge. plugins/omi-notion-app/main.py
plugins/omi-notion-app/test_notion_security.py
Verification: I ran the suite hermetically (stdlib doubles only, no network, no third-party deps): 10/10 pass. The Hygiene lane also ran notion-app-security-tests on this head and it passed — this is the first in-repo CI execution (it was skipped on the previous head by the fork gate), so the earlier request to see it run in the real lane is satisfied. .github/checks-manifest.yaml is unchanged since the earlier review; the registration remains correctly scoped. Still an OAuth-callback security change, so security-review stays on for maintainer sign-off before merge — the code itself looks correct to me. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
aryanorastar
left a comment
There was a problem hiding this comment.
Approved 2249870a71c59cb59024714ebc23b97e4a0e8c68. plugins/omi-notion-app/main.py on main still interpolates a raw uid into /?uid=. This head encodes it and Hygiene succeeded.
|
This is a later copy of #13658, which already percent-encodes the Notion uid links and the disconnect redirect. This head only edits that same |
|
Hey @kaleidoscopeAI 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Resolves #15011
Fresh PR off current main — supersedes #15013, which has drifted and no longer merges cleanly.
The error-parameter half of #15011 already landed via #14503 (the callback error is HTML-escaped on main). This PR completes the remaining half: percent-encode the reflected
uidat every outbound-URL interpolation in the Notion app, per FC-uid-reflected-unencoded-in-remaining-apps.Changes (
plugins/omi-notion-app/main.py):quote(clean_uid, safe='')for the connect link, HTML-escaped once intosafe_auth_urlquote(clean_uid, safe='')for the disconnect link, HTML-escaped once intosafe_disconnect_urlsafe_continue_url = html.escape(f"/?uid={quote(uid, safe='')}", quote=True)— closes the attribute-breakout vector (/?uid={uid}was interpolated raw)/disconnectredirect:quote(clean_uid, safe='')in theLocationtargetOptional[str]withisinstanceguards so a hostile non-string query value fails closed instead of renderingTests (
plugins/omi-notion-app/test_notion_security.py):Hermetic suite — framework doubles injected via
patch.dict(sys.modules, ...), so fastapi/requests/dotenv are not required and it runs in the Hygiene lane:/auth/notion,/setup/notion,/disconnectreject malformed uidsattacker" onfocus="alert(1)renders asattacker%22%20onfocus%3D%22alert%281%29), keeping the HTML attribute intactRegistered in
.github/checks-manifest.yamlasnotion-app-security-tests(triggers onplugins/omi-notion-app/**and.github/checks-manifest.yaml).Failure-Class: FC-uid-reflected-unencoded-in-remaining-apps