Skip to content

fix(mesh): validate redirect_uri in oauth-proxy to prevent OAuth hijacking#3110

Merged
viktormarinho merged 5 commits intodecocms:mainfrom
0xcucumbersalad:fix/oauth-proxy-redirect-uri-validation
Apr 14, 2026
Merged

fix(mesh): validate redirect_uri in oauth-proxy to prevent OAuth hijacking#3110
viktormarinho merged 5 commits intodecocms:mainfrom
0xcucumbersalad:fix/oauth-proxy-redirect-uri-validation

Conversation

@0xcucumbersalad
Copy link
Copy Markdown
Contributor

@0xcucumbersalad 0xcucumbersalad commented Apr 13, 2026

The oauth-proxy authorize endpoint was forwarding any redirect_uri to the upstream auth server without validation. An attacker could supply a malicious redirect_uri (e.g. https://evil.com) and steal authorization codes after consent.

Now the proxy requires redirect_uri and rejects any host that is not studio.decocms.com (or subdomains) or localhost/127.0.0.1.


Summary by cubic

Secures the oauth-proxy authorize endpoint by validating redirect_uri (optional per RFC 6749) to prevent OAuth hijacking. If present, its origin must match getSettings().baseUrl (or the request origin); invalid values return 400 invalid_request and duplicate redirect_uri params are collapsed to a single validated value.

Written for commit 21c0be5. Summary will update on new commits.

…cking

The oauth-proxy authorize endpoint was forwarding any redirect_uri to the
upstream auth server without validation. An attacker could supply a
malicious redirect_uri (e.g. https://evil.com) and steal authorization
codes after consent.

Now the proxy requires redirect_uri and rejects any host that is not
studio.decocms.com (or subdomains) or localhost/127.0.0.1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Release Options

Suggested: Patch (2.262.3) — based on fix: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.262.3-alpha.1
🎉 Patch 2.262.3
❤️ Minor 2.263.0
🚀 Major 3.0.0

Current version: 2.262.2

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mesh/src/api/app.ts">

<violation number="1" location="apps/mesh/src/api/app.ts:672">
P1: `redirect_uri` validation only checks one occurrence, but duplicate `redirect_uri` params are still forwarded, enabling potential authorize-flow bypass via parser differences.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

decobot and others added 2 commits April 14, 2026 01:54
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per RFC 6749 §4.1.1, redirect_uri is not always required. Only validate
it when present to avoid breaking authorize requests that omit it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mesh/src/api/app.ts">

<violation number="1" location="apps/mesh/src/api/app.ts:673">
P2: Missing redirect_uri now bypasses validation: the authorize handler only checks allowlisted origins when redirect_uri is present, so requests without it are forwarded upstream with no local enforcement.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

redirectHost === "localhost" ||
redirectHost === "127.0.0.1" ||
redirectHost === "studio.decocms.com" ||
redirectHost.endsWith(".studio.decocms.com");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseurl

decobot and others added 2 commits April 14, 2026 20:48
…d hosts

Use getSettings().baseUrl (falling back to request origin) to validate
the redirect_uri origin, instead of a hardcoded allowlist of hostnames.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Canonicalize redirect_uri with searchParams.set() after validation so
duplicate params are collapsed to the single checked value, closing a
parser-differential bypass vector.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@viktormarinho viktormarinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@viktormarinho viktormarinho merged commit 22b5ef7 into decocms:main Apr 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants