Am I affected?
Description
Improper Verification of Cryptographic Signature vulnerability in dashbit nimble_zta allows an unauthenticated remote attacker to authenticate as an arbitrary Cloudflare service token. Applications using the Cloudflare Zero Trust authentication strategy are affected.
verify_token/2 in lib/nimble_zta/cloudflare.ex matches the result of JOSE.JWT.verify/2 against {_, token, _s}, which discards the boolean verification result and returns the decoded token after a failed signature check. The attacker sends a forged JWT in the cf-access-jwt-assertion header, carrying the expected iss claim and the seven service token claims. verify_iss/2 reads the iss claim from the forged token, so it rejects nothing, and the service token path then returns those claims as the authenticated identity.
This issue affects nimble_zta: from 0.1.2 before 0.1.3.
Proof of concept
- Build a JWT payload that carries the
aud,common_name,exp,iat,iss,subandtypeclaims. Use theissthe application expects, setexpto a future timestamp, and setcommon_nameto the service token to impersonate. - Append any signature segment. The segment must be present, because
JOSE.JWT.verify/2needs three segments to parse the token. The signature does not need to verify against the Cloudflare keys. - Send a request to the application with the forged JWT in the
cf-access-jwt-assertionheader. NimbleZTA.Cloudflare.authenticate/3returns the claims of the forged token as the authenticated identity, with thestrategyfield set toservice_token.
Weaknesses & attack patterns
Weakness
CWE-347
·
Improper Verification of Cryptographic Signature
in catalog →
MITRE ↗
Attack patterns
CAPEC-475
·
Signature Spoofing by Improper Validation
MITRE ↗
The attacker authenticates as an arbitrary Cloudflare service token without holding the Cloudflare signing key. The application receives the client_id and the claims of the forged token as the authenticated identity, so the attacker gets the access that the application grants to that service token.
Affected — Hex / nimble_zta Hex.pm ↗ Repository ↗
modules · source files · routines
Affected — GitHub / dashbitco/nimble_zta Repository ↗
modules · source files · routines
Workarounds
Disable the Cloudflare authentication strategy.
To keep the user identity strategy available, reject the service token requests yourself. Examine each request before you call NimbleZTA.Cloudflare.authenticate/3, and reject it if its JWT carries the common_name claim and the type claim.
Configurations
The application must add NimbleZTA.Cloudflare to its supervision tree and authenticate requests through it.
References
Credits
CVSS breakdown
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:H/SA:N