-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The dispatcher has five named branches. The default arm has no password check.\n\n`static_content` is declared as `/static//`. Flask's `` URL converter forbids slashes inside either component, so the URL grammar pre-rejects multi-segment traversal in `filename`. Inside the handler, `group` switches over five cases:\n\n```python\n@app.route(\"/static//\", methods=['GET'])\ndef static_content(group, filename):\n from flask import make_response\n import re\n group = re.sub(r'[^\\w.-]+', '', group.lower())\n filename = re.sub(r'[^\\w.-]+', '', filename.lower())\n\n if group == 'screenshot':\n # Could be sensitive, follow password requirements\n if datastore.data['settings']['application']['password'] and not flask_login.current_user.is_authenticated:\n if not datastore.data['settings']['application'].get('shared_diff_access'):\n abort(403)\n # ... serve last-screenshot.png from the datastore\n\n if group == 'favicon':\n # Could be sensitive, follow password requirements\n if datastore.data['settings']['application']['password'] and not flask_login.current_user.is_authenticated:\n abort(403)\n # ... serve favicon from the watch's data directory\n\n if group == 'visual_selector_data':\n # Could be sensitive, follow password requirements\n if datastore.data['settings']['application']['password'] and not flask_login.current_user.is_authenticated:\n abort(403)\n # ... serve elements.deflate from the watch directory\n\n if group == 'plugin':\n # ... iterate registered plugins and serve their static files\n\n # These files should be in our subdirectory\n try:\n return send_from_directory(f\"static/{group}\", path=filename)\n except FileNotFoundError:\n abort(404)\n```\n\nThree of the four named branches carry an explicit password gate. The fourth (`plugin`) walks the registered plugin list and serves files from each plugin's declared static directory. The unnamed fifth branch, the default fallthrough, has no password check because the legitimate set of values it serves is the contents of `changedetectionio/static/`: CSS, JavaScript, images, the sort of asset that ships to every visitor of every page before login. Static assets are public.\n\nThe author's authorization model is: the set of \"sensitive\" groups is enumerated, each enumerated case enforces its own password gate, and anything outside the enumeration is a public static asset by definition. The model is correct for the four values the author had in mind. The model assumes `group` is one of those four values or a directory name under `static/`. The model has no failure case for a `group` that is neither.\n\n## The character class admits the two characters that name a directory's parent\n\n`re.sub(r'[^\\w.-]+', '', \"..\")` returns `\"..\"`. The class `[^\\w.-]+` strips any character that is not a word character, a period, or a hyphen. Both characters in `..` are periods. Nothing is stripped.\n\n`..` matches none of the four named branches. The handler falls through to the default arm:\n\n```python\nreturn send_from_directory(f\"static/{group}\", path=filename)\n```\n\nwhich expands, for `group=\"..\"` and `filename=\"flask_app.py\"`, to:\n\n```python\nreturn send_from_directory(\"static/..\", path=\"flask_app.py\")\n```\n\n`send_from_directory` joins the directory argument against the application root and normalises the result before joining the filename. `static/..` normalises to `changedetectionio/`. The filename URL converter has already forbidden slashes in `flask_app.py`, so the join resolves to `/app/changedetectionio/flask_app.py`. Werkzeug's path-safety check confirms the result is inside the normalised base. The base was the parent of `static/`. The result is.\n\n```\n$ curl -i http://target:5000/static/%2e%2e/flask_app.py\nHTTP/1.1 200 OK\nContent-Type: text/x-python; charset=utf-8\nContent-Length: 47214\n\nimport datetime\nimport flask_login\nimport locale\nimport os\nimport queue\nimport threading\nimport time\nimport timeago\n...\n```\n\nThe response body is the 1,164-line source of the handler the request just executed.\n\n## Thirty lines above, the same author wrote the strict version\n\n`static_flags` is declared eleven lines below the URL-prefix middleware and thirty lines above `static_content`. It serves country-flag SVGs for the watch-status UI, and the URL it answers is `/static/flags/`:\n\n```python\n@app.route(\"/static/flags/\", methods=['GET'])\ndef static_flags(flag_path):\n \"\"\"Handle flag icon files with subdirectories\"\"\"\n from flask import make_response\n import re\n\n # flag_path comes in as \"1x1/de.svg\" or \"4x3/de.svg\"\n if re.match(r'^(1x1|4x3)/[a-z0-9-]+\\.svg$', flag_path.lower()):\n parts = flag_path.lower().split('/')\n if len(parts) != 2:\n abort(404)\n\n subdir = parts[0]\n svg_file = parts[1]\n\n # Extra validation: ensure subdir is exactly 1x1 or 4x3\n if subdir not in ['1x1', '4x3']:\n abort(404)\n\n # Extra validation: ensure svg_file only contains safe characters\n if not re.match(r'^[a-z0-9-]+\\.svg$', svg_file):\n abort(404)\n\n try:\n response = make_response(send_from_directory(f\"static/flags/{subdir}\", svg_file))\n response.headers['Content-type'] = 'image/svg+xml'\n response.headers['Cache-Control'] = 'max-age=86400, public'\n return response\n except FileNotFoundError:\n abort(404)\n else:\n abort(404)\n```\n\nThe route is declared with ``, which DOES permit slashes, so the handler is the only thing between the URL and the filesystem. It responds with four layers: an anchored match against an enumerated alternation, a split-and-recheck of length, an explicit `subdir not in ['1x1', '4x3']` rejection, and a second anchored match on the filename half. Each layer narrows the accepted set against a value the author can name aloud.\n\n`static_content` ships with none of these. The route converter is `` instead of ``, which carries one layer for free (no slashes inside the filename). The handler then applies one substitution, not a match, against a character class permissive enough to ship every value the author wanted plus every value they did not. The same author who, thirty lines above, wrote `if subdir not in ['1x1', '4x3']: abort(404)` against a set with two members did not write `if group not in ['screenshot', 'favicon', 'visual_selector_data', 'plugin']: ...` against a set with four.\n\n## Convention Is The Allowlist\n\nThe set of legitimate `group` values lives in the dispatcher's switch. The author knows the values; the values are the four `if group == '...':` string literals plus whatever subdirectory names exist under `static/`. None of those values contains a period. The author's mental model of `group` is \"one of a dozen short identifiers.\"\n\nThe implemented model is \"any string that survives `re.sub(r'[^\\w.-]+', '', x.lower())`.\" This is the [Convention Is The Allowlist](https://nefariousplan.com/posts/erlang-otp-cve-2025-32433-authenticated-was-tracked-never-gated) shape applied to an HTTP route dispatcher. The spec author's implicit allowlist (the dispatcher's enumeration) is not the code's allowlist (the regex's character class). The set the code accepts is whatever the broad syntactic type admits, and the broad syntactic type was chosen for a different field.\n\nThe other field is `filename`. Filenames in `changedetectionio/static/` include `chart.min.js`, `pikaday.css`, `apexcharts.min.js`, `style.scss`. Each has at least one period. The class `[^\\w.-]+` was the right shape for `filename`. The author then applied the same regex to `group` because the substitution call already existed two lines above and `group` is also a string the user controls. One field needed the period in the class. The other field shared it.\n\n## What the attacker can actually read\n\nFlask's `` converter forbids slashes, so the traversal cannot ascend beyond `changedetectionio/`. The GHSA records this as the limitation that holds CVSS at 5.3 (C:L) and notes that the route \"cannot traverse further to arbitrary system paths like `/etc/passwd`.\" The advisory does not enumerate what `changedetectionio/` does contain. The relevant flat-file Python sources at that directory in 0.52.9:\n\n| File | What it carries |\n|------|------|\n| `flask_app.py` | every route, every handler, every middleware |\n| `auth_decorator.py` | the `login_optionally_required` decorator and its session model |\n| `is_safe_url.py` | the SSRF allowlist and the IANA-restricted-address logic |\n| `validate_url.py` | URL parsing for the watch URL field |\n| `notification_service.py` | the Apprise integration and the credential handling around it |\n| `pluggy_interface.py` | the plugin loader and its trust model |\n| `store.py` | the datastore layout and the on-disk key set |\n| `forms.py` | every WTForms field, every validator, every choice constant |\n| `html_tools.py` | every parser the watch pipeline hands untrusted HTML, XML, and RSS to |\n\nThe CVSS impact rating reflects what the attacker reads as a finished primitive. The map of every URL-fetching codepath, every IP-allowlist check, every parser the backend hands untrusted bytes to, and every authentication branch in the application is the input to whatever the attacker hunts next. The same project shipped CVE-2026-29039 (XPath `unparsed-text()` arbitrary file read), CVE-2026-41895 (XXE in the XPath helper), and CVE-2026-43891 (arbitrary local file read via backup restore) in the months that followed the 0.52.9 release. Each of those bugs lives in one of the files in the table above. The pre-patch source map was unauthenticated for anyone who knew the route existed.\n\n## The patch deletes the sanitizer that needed the period\n\n```diff\n- group = re.sub(r'[^\\w.-]+', '', group.lower())\n- filename = re.sub(r'[^\\w.-]+', '', filename.lower())\n+ # Strict sanitization: only allow a-z, 0-9, and underscore (blocks .. and other traversal)\n+ group = re.sub(r'[^a-z0-9_-]+', '', group.lower())\n+ filename = filename\n+\n+ # Additional safety: reject if sanitization resulted in empty strings\n+ if not group or not filename:\n+ abort(404)\n```\n\nTwo lines removed, four lines added. The `group` regex's character class loses the period and gains an underscore (cosmetic, since `\\w` already includes underscore in Python's `re`). The `filename` sanitizer is deleted; the author now trusts Flask's `` URL converter to forbid the slash and accepts whatever character set remains. The \"two fields, one regex\" regime becomes \"two fields, two regimes.\" The fields had two different threat models all along.\n\nThe patch's own comment names the change: `# Strict sanitization: only allow a-z, 0-9, and underscore (blocks .. and other traversal)`. The comment frames the pre-patch regex as \"loose sanitization\" that needed to be tightened. The pre-patch regex was not loose sanitization in the abstract. It was sanitization for `filename` that the author also ran on `group` because the line above was already running it.\n\nThe post-patch handler still does not enumerate the legitimate values of `group`. It still has no `if group not in [...]: abort(404)`. It still dispatches the unknown-group case to the default `send_from_directory` arm with no password check. Anything that survives `[^a-z0-9_-]+` and matches a subdirectory under `static/` is served. The change closes the demonstrated chain; the dispatcher's open-set authorization model is unchanged. The character class is tighter; the convention is still the allowlist.\n\nPoC: [projectdiscovery/nuclei-templates](https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2026/CVE-2026-25527.yaml).","closing_line":"The dot was in the character class because filenames have dots. The dispatcher tag did not. The regex shipped to both fields for two years anyway.","hook_md":"changedetection.io 0.52.9's `/static//` handler sanitizes both URL components with one expression: `re.sub(r'[^\\w.-]+', '', x.lower())`. The character class allows letters, digits, underscore, period, and hyphen. The period is in the class because filenames have periods. Thirty lines above `static_content` in the same file, the same author wrote `static_flags` with anchored matching and a hardcoded enumeration of the two values it accepts.\n\nCVE-2026-25527 is what `static_content` inherited that `static_flags` refused: the character allowlist filenames need, applied to a dispatcher tag whose convention has four legal values.","post_id":590,"slug":"changedetection-io-cve-2026-25527-static-handler-shared-the-filename-regex","title":"CVE-2026-25527: changedetection.io's /static/ Handler Sanitized the Dispatcher Tag With the Regex Written for the Filename","type":"initial","unreadable_sentence":"The pre-patch regex was not loose sanitization. It was sanitization for the other field."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCasABBQAKCRDeZjl4jgkQ JoLdAP42zK6LoJ4Lgq9ycUZ4c1vgY5vGmuEzzYN8+JmDITV+WQEAmf1A1f332SS3 3A5R9EuDmWItEheE3MA+ka95fFnTuAo= =qlRe -----END PGP SIGNATURE-----