Skip to content

fix(auth): validate tenantId and providerId against URL path traversal - #3292

Merged
macastelaz merged 6 commits into
mainfrom
fix-tenant-provider-id-validation
Oct 21, 2026
Merged

macastelaz merged 6 commits into
mainfrom
fix-tenant-provider-id-validation

Conversation

@macastelaz

Copy link
Copy Markdown
Contributor

Description

Validates tenantId and OIDC/SAML providerId resource identifiers against URL path traversal, dot-segments (., .., ..., trailing .), query/fragment injection (?, #, &), and percent-encoded sequences (%) before interpolating them into Identity Toolkit REST API URLs:

  • Adds validator.isTenantId(tenantId) enforcing that tenant IDs are non-empty strings consisting of RFC 3986 unreserved characters ([a-zA-Z0-9-_.~]) that do not end with ..
  • Applies validator.isTenantId(tenantId) in TenantManager.authForTenant, TenantAwareAuth, AuthRequestHandler.getTenant, AuthRequestHandler.deleteTenant, AuthRequestHandler.updateTenant, TenantAwareAuthRequestHandler, and validateCreateEditRequest.
  • Updates SAMLConfig.isProviderId, SAMLConfig.validate, OIDCConfig.isProviderId, and OIDCConfig.validate to require a non-empty suffix after saml. / oidc. consisting of [a-zA-Z0-9-_.~] and not ending with ..
  • Adds unit tests covering malformed tenant IDs and OIDC/SAML provider IDs across validator, TenantManager, TenantAwareAuth, SAMLConfig, OIDCConfig, and AuthRequestHandler.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces stricter validation for tenant IDs and provider IDs (SAML and OIDC) across the authentication module, replacing basic non-empty string checks with regex-based validation and adding a new isTenantId utility. While these changes improve input validation, the review feedback identifies a security vulnerability in the regular expressions used in auth-config.ts and validator.ts. Specifically, the unescaped hyphen in the character class [a-zA-Z0-9-_.~] is interpreted as a range (9-_), which inadvertently permits dangerous characters like ?, @, and \. Escaping the hyphens is highly recommended to prevent potential validation bypasses.

Comment thread src/auth/auth-config.ts Outdated
Comment thread src/auth/auth-config.ts Outdated
Comment thread src/utils/validator.ts Outdated
@macastelaz
macastelaz marked this pull request as ready for review October 20, 2026 16:29
@macastelaz
macastelaz requested a review from a team October 20, 2026 16:29
@lahirumaramba lahirumaramba added release-note release:stage Stage a release candidate labels Oct 21, 2026

@lahirumaramba lahirumaramba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Added a nit comment. Thanks!

Comment thread src/auth/auth-config.ts Outdated
@macastelaz
macastelaz merged commit 2fe7205 into main Oct 21, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:stage Stage a release candidate release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants