Описание
SciTokens has an Authorization Bypass via Path Traversal in Scope Validation
Summary
The Enforcer is vulnerable to a path traversal attack where an attacker can use dot-dot (..) in the scope claim of a token to escape the intended directory restriction. This occurs because the library normalizes both the authorized path (from the token) and the requested path (from the application) before comparing them using startswith.
Details
File: src/scitokens/scitokens.py
Methods: _check_scope, _scope_path_matches
File: src/scitokens/urltools.py
Method: normalize_path
Description
When a token is verified, the Enforcer extracts the authorized path from the scope or scp claim. This path is passed through urltools.normalize_path, which uses posixpath.normpath to resolve relative segments.
If a token has a scope like read:/home/user1/.., the normalization process converts this to /home. When the enforcer checks if a request for /home/user2 is authorized, it compares it against the normalized path /home.
Vulnerable Logic Flow:
- Normalization: In
_check_scope, the path/home/user1/..is normalized to/home. - Comparison: In
_scope_path_matches, the requested path/home/user2is checked against the allowed path/home:return requested_path.startswith(allowed_path + '/') # "/home/user2".startswith("/home/") is True
Bypassing with URL Encoding:
Since normalize_path unquotes the path before normalizing, an attacker can also use URL-encoded dots (e.g., %2e%2e) to hide the traversal from simple string filters that don't account for encoding.
Root Traversal:
A scope like read:/anything/.. normalizes to read:/, which grants access to the entire file system (or whatever resource space the enforcer is guarding).
Impact
An attacker who can influence the scope claim (e.g., in environments where tokens are issued with user-provided sub-paths) can gain access to directories and files outside of their intended authorization.
Proof of Concept
The following examples demonstrate the bypass (see poc_path_traversal.py for a full reproduction):
- Scope:
read:/home/user1/..-> Access Granted to:/home/user2 - Scope:
read:/anything/..-> Access Granted to:/etc/passwd - Scope:
read:/foo/%2e%2e/bar-> Access Granted to:/bar
Recommended Fix
Validate that the path in the scope does not contain .. components after unquoting but before normalization. Additionally, ensure that any validation errors raised during this process are subclasses of ValidationFailure so they are correctly handled by the Enforcer.test method.
Ссылки
- https://github.com/scitokens/scitokens/security/advisories/GHSA-3x2w-63fp-3qvw
- https://nvd.nist.gov/vuln/detail/CVE-2026-32727
- https://github.com/scitokens/scitokens/pull/230
- https://github.com/scitokens/scitokens/commit/2d1cc9e42bc944fe0bbc429b85d166e7156d53f9
- https://github.com/scitokens/scitokens/releases/tag/v1.9.7
Пакеты
scitokens
< 1.9.7
1.9.7
Связанные уязвимости
SciTokens is a reference library for generating and using SciTokens. Prior to version 1.9.7, the Enforcer is vulnerable to a path traversal attack where an attacker can use dot-dot (..) in the scope claim of a token to escape the intended directory restriction. This occurs because the library normalizes both the authorized path (from the token) and the requested path (from the application) before comparing them using startswith. This issue has been patched in version 1.9.7.