Skip to content

fix: ssrf validation for oauth#39505

Merged
dionisio-bot[bot] merged 2 commits intodevelopfrom
fix/oauth-ssrf
Mar 10, 2026
Merged

fix: ssrf validation for oauth#39505
dionisio-bot[bot] merged 2 commits intodevelopfrom
fix/oauth-ssrf

Conversation

@KevLehman
Copy link
Copy Markdown
Member

@KevLehman KevLehman commented Mar 10, 2026

Proposed changes (including videos or screenshots)

Issue(s)

Fixes #39328

Steps to test or reproduce

Further comments

Task: CORE-1938

Summary by CodeRabbit

  • Bug Fixes
    • Fixed SSRF (Server-Side Request Forgery) validation in OAuth endpoints to enhance security and prevent internal endpoints from being accessed during the authentication flow.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 10, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 10, 2026

🦋 Changeset detected

Latest commit: aea73a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 10, 2026

Walkthrough

A patch was released that disables SSRF validation for OAuth token and identity endpoint requests by adding ignoreSsrfValidation: true to the fetch calls, resolving broken OAuth login flows introduced in version 8.2.0.

Changes

Cohort / File(s) Summary
Changelog Entry
.changeset/unlucky-impalas-matter.md
New changelog documenting the SSRF validation fix for OAuth endpoints.
OAuth Server Configuration
apps/meteor/app/custom-oauth/server/custom_oauth_server.js
Added ignoreSsrfValidation: true flag to token fetch request in getAccessToken and identity fetch request in getIdentity to bypass SSRF validation for OAuth external requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

type: bug, area: authentication

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: ssrf validation for oauth' clearly and concisely describes the main change: fixing SSRF validation issues in OAuth endpoints, which matches the PR's primary objective.
Linked Issues check ✅ Passed The PR addresses both linked issues by disabling SSRF validation for OAuth requests (#39328, CORE-1938), allowing internal endpoints to be used during OAuth flows as required.
Out of Scope Changes check ✅ Passed The changelog entry and OAuth endpoint modifications are directly scoped to fixing SSRF validation for OAuth flows; no unrelated changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@KevLehman
Copy link
Copy Markdown
Member Author

/jira CORE

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.91%. Comparing base (18a9921) to head (aea73a1).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39505      +/-   ##
===========================================
+ Coverage    70.88%   70.91%   +0.02%     
===========================================
  Files         3197     3197              
  Lines       113337   113337              
  Branches     20531    20530       -1     
===========================================
+ Hits         80342    80374      +32     
+ Misses       30948    30913      -35     
- Partials      2047     2050       +3     
Flag Coverage Δ
e2e 60.42% <ø> (+0.03%) ⬆️
e2e-api 48.76% <ø> (+0.99%) ⬆️
unit 71.61% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KevLehman KevLehman marked this pull request as ready for review March 10, 2026 15:53
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.

No issues found across 2 files

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/app/custom-oauth/server/custom_oauth_server.js (1)

139-145: ⚠️ Potential issue | 🔴 Critical

Don't bypass SSRF protection for configurable OAuth endpoints.

ignoreSsrfValidation: true disables the full private-range / metadata / DNS-pinning guard for both requests, and this.tokenPath / this.identityPath are built from admin-configurable provider URLs. That turns a login regression fix into a blanket SSRF escape hatch and can leak the client secret or bearer token to internal services. Please keep validation on and solve the internal-IdP case with a narrow allowlist or an explicit opt-in for private-network OAuth endpoints instead of disabling the guard entirely.

Also applies to: 179-180

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/custom-oauth/server/custom_oauth_server.js` around lines 139
- 145, The fetch calls that use this.tokenPath and this.identityPath must not
set ignoreSsrfValidation: true; remove that flag and keep SSRF validation
enabled, and implement a safe opt-in/allowlist for private-network IdPs instead:
validate the configured provider URL with the existing SSRF validator before
calling fetch, or add an explicit admin-only provider flag (e.g.,
provider.allowPrivateNetworkOAuth or global allowPrivateOAuth) that, when set,
records consent and runs a narrow hostname/CIDR allowlist check before
permitting internal-network requests; apply this change to the fetch usage
around tokenPath and the similar identityPath fetch (the same pattern at the
other location mentioned) so no blanket SSRF bypass is used.
🧹 Nitpick comments (1)
apps/meteor/app/custom-oauth/server/custom_oauth_server.js (1)

140-140: Remove the new inline SECURITY comments.

Please keep the rationale in the PR/commit message or an extracted helper name instead of implementation comments.

As per coding guidelines: "Avoid code comments in the implementation".

Also applies to: 179-179

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/custom-oauth/server/custom_oauth_server.js` at line 140,
Remove the inline "SECURITY" comments in
apps/meteor/app/custom-oauth/server/custom_oauth_server.js (the comments at the
URL-configuration check and the similar one later) and instead capture the
rationale outside the implementation—either in the PR/commit message or by
renaming the helper/function involved to make intent explicit (e.g., change the
helper name that controls the URL check to something self-documenting like
allowUrlConfigOnlyForPrivilegedUsers). Do not leave explanatory comments in the
code; ensure the code itself and any helper names clearly convey why the check
is relaxed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/meteor/app/custom-oauth/server/custom_oauth_server.js`:
- Around line 139-145: The fetch calls that use this.tokenPath and
this.identityPath must not set ignoreSsrfValidation: true; remove that flag and
keep SSRF validation enabled, and implement a safe opt-in/allowlist for
private-network IdPs instead: validate the configured provider URL with the
existing SSRF validator before calling fetch, or add an explicit admin-only
provider flag (e.g., provider.allowPrivateNetworkOAuth or global
allowPrivateOAuth) that, when set, records consent and runs a narrow
hostname/CIDR allowlist check before permitting internal-network requests; apply
this change to the fetch usage around tokenPath and the similar identityPath
fetch (the same pattern at the other location mentioned) so no blanket SSRF
bypass is used.

---

Nitpick comments:
In `@apps/meteor/app/custom-oauth/server/custom_oauth_server.js`:
- Line 140: Remove the inline "SECURITY" comments in
apps/meteor/app/custom-oauth/server/custom_oauth_server.js (the comments at the
URL-configuration check and the similar one later) and instead capture the
rationale outside the implementation—either in the PR/commit message or by
renaming the helper/function involved to make intent explicit (e.g., change the
helper name that controls the URL check to something self-documenting like
allowUrlConfigOnlyForPrivilegedUsers). Do not leave explanatory comments in the
code; ensure the code itself and any helper names clearly convey why the check
is relaxed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 177bc36b-0366-49bc-a8bd-9ca6bec672bc

📥 Commits

Reviewing files that changed from the base of the PR and between 18a9921 and aea73a1.

📒 Files selected for processing (2)
  • .changeset/unlucky-impalas-matter.md
  • apps/meteor/app/custom-oauth/server/custom_oauth_server.js
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/custom-oauth/server/custom_oauth_server.js
🧠 Learnings (3)
📚 Learning: 2026-03-09T23:46:48.340Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 39492
File: apps/meteor/app/oauth2-server-config/server/oauth/oauth2-server.ts:22-24
Timestamp: 2026-03-09T23:46:48.340Z
Learning: In `apps/meteor/app/oauth2-server-config/server/oauth/oauth2-server.ts`, the `oAuth2ServerAuth` function's `authorization` field in `partialRequest` is exclusively expected to carry Bearer tokens. Basic authentication is not supported in this OAuth flow, so there is no need to guard against non-Bearer schemes when extracting the token from the `Authorization` header.

Applied to files:

  • apps/meteor/app/custom-oauth/server/custom_oauth_server.js
📚 Learning: 2026-02-24T19:09:09.561Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.

Applied to files:

  • apps/meteor/app/custom-oauth/server/custom_oauth_server.js
  • .changeset/unlucky-impalas-matter.md
📚 Learning: 2026-02-24T19:05:56.710Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.

Applied to files:

  • .changeset/unlucky-impalas-matter.md
🔇 Additional comments (1)
.changeset/unlucky-impalas-matter.md (1)

5-5: Security controls for OAuth SSRF validation are in place and properly documented in the code. The OAuth provider URLs can only be configured by workspace administrators (via the add-oauth-service permission restricted to admin role), making the SSRF validation bypass acceptable and secure. The implementation includes explicit security comments explaining this rationale.

@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Mar 10, 2026
@KevLehman KevLehman added this to the 8.3.0 milestone Mar 10, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Mar 10, 2026
@dionisio-bot dionisio-bot bot enabled auto-merge March 10, 2026 16:10
@dionisio-bot dionisio-bot bot added this pull request to the merge queue Mar 10, 2026
Merged via the queue into develop with commit 0a53619 Mar 10, 2026
112 of 117 checks passed
@dionisio-bot dionisio-bot bot deleted the fix/oauth-ssrf branch March 10, 2026 18:26
@KevLehman
Copy link
Copy Markdown
Member Author

/patch

dionisio-bot bot pushed a commit that referenced this pull request Mar 10, 2026
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 10, 2026

Pull request #39517 added to Project: "Patch 8.2.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[8.2.0] OAuth login broken since 8.2.0

3 participants