Repository navigation
fix(sso): trust mpass identity headers only from traefik and verify the token - #8
Merged
Merged
Conversation
…he token Honour X-Auth-Request-* only when X-Mpass-Edge-Secret matches MPASS_EDGE_SECRET, and verify the forwarded token against the issuer JWKS before the SMB corporate check. FOSS-778
A logged-in session no longer depends on the forwarded token being fresh or the JWKS being reachable on every request. FOSS-778
…h failure Declare jwt directly in the Gemfile. FOSS-778
zammad-ci:latest moved to a newer ruby and pre.sh rejects the Gemfile's 3.4.9 pin.
The EOL date passed, which changed the warning's fingerprint and left the existing ignore entry obsolete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ZAMMAD_EDGE_SECRET, Traefik set/strip middlewares,x-zammad-env) and the zammad-mcp-server mint change. Without the secret this image ignores every identity header, so SSO and zammad-mcp token minting both stop working.lib/zammad/mpass_proxy_auth.rbacceptedX-Auth-Request-*from any caller that reachedzammad-nginxorzammad-railsserveron the Dockerbackendnetwork, and base64-decoded the forwarded token without checking its signature. A forged email header also overrode an API token.lib/zammad/mpass_edge_trust.rb(new):X-Mpass-Edge-Secretcompared withMPASS_EDGE_SECRETviaActiveSupport::SecurityUtils.secure_compare. Empty, shorter than 32 characters or aCHANGE_ME_value trusts nothing.lib/zammad/mpass_proxy_auth.rb(rewritten):HTTP_X_AUTH_REQUEST_*key is deleted from the Rack env before anything reads it, so nothing logs in, creates a user or switches the session. A warning logs the mPass id, path and addresses, never the email.X-Mpass-Edge-Secretis always removed from the env.SMB_CORPORATE_IDis set but no issuer or client id is configured.lib/zammad/mpass_token_verifier.rb(new): RS256 only;exp,iat,iss,token_userequired; 60s leeway. Issuers:MPASS_COGNITO_ISSUER_URL(fallback region + pool id) and optionalMPASS_TOKEN_ISSUER_URL. Audience:client_idoraudmust beMPASS_OIDC_CLIENT_IDorMPASS_MCP_OIDC_CLIENT_ID(zammad-mcp can sign in with its own Cognito client).lib/zammad/mpass_jwks_cache.rb(new): one key set per issuer, 1h cache, 2s timeout, 30s backoff after a failed fetch.jwks_unavailable.Gemfile:gem 'jwt', '~> 3.2'pinned explicitly. It was already in the lockfile through other gems; the lockfile resolution is unchanged.foss-mainrun fail without it since late October):.github/workflows/ci.yaml: pinszammad/zammad-cito the digest of the last green run (Ruby 3.4.9). The movinglatesttag now ships Ruby 4.0.9, which failsbundle installagainst the Gemfile's 3.4.9. Unpin when Ruby is bumped on the next upstream sync.config/brakeman.ignore: refreshes the existing upstream ignore for the Rails 8.0 end-of-life warning, whose fingerprint changed after 2026-11-07.doc/mpass_sso.md: new env vars and the security section.HttpLogmasking already filters both headers; a new request spec proves it./wswebsocket process (session cookies), the WhatsApp webhook bypass.Testing
bundle exec rspec spec/lib/zammad/ spec/requests/application_controller/logs_http_access_spec.rb(RAILS_ENV=test CI_SKIP_ASSETS_PRECOMPILE=1 VITE_TEST_MODE=1, throwaway container): 177 examples, 0 failures. Rubocop clean on touched files.alg=noneand HS256 tokens; missing claims; futureiat; JWKS failure, non-JSON body, backoff, stale-set grace, concurrent fetches; gate unset means no JWKS fetch.zammad:dev7.1.2 image, scratch override for the secret and middlewares):X-Auth-Request-Emailtozammad-nginx:8080with no secret or a wrong one: 403, no user created./users/meand/tickets: 200. Minted token plus a forged email for another agent: 200 as the token owner.SMB_CORPORATE_ID, refused withwrong_organization, reached only after the real token passed signature, issuer and audience checks.