Invia #1078366: Agent Zero 2026-11-06 CWE-306informazioni

TitoloAgent Zero 2026-11-06 CWE-306
DescrizioneA vulnerability was found in Agent Zero. It has been classified as critical. In its default deployment, in which no AUTH_LOGIN is configured, a chain of four HTTP requests starting with no credentials at all ends in root command execution. The authentication dependency helpers/api.py:175-187 returns without raising when login.get_credentials_hash() yields None, and helpers/login.py:5-10 only consults AUTH_LOGIN, which none of the three startup scripts set. Every endpoint declaring requires_auth therefore serves anonymously. Link 1: GET /api/csrf_token. No credentials. Its origin gate calls initialize_allowed_origins(), which appends the first non-localhost Origin it sees to the persisted ALLOWED_ORIGINS list, so an attacker-chosen Origin whitelists itself. The response carries the CSRF token and runtime_id. Link 2: POST /api/settings_get. No credentials, with the CSRF token from link 1. helpers/settings.py convert_out (lines 273-370) masks api_keys, auth_password, rfc_password, root_password and secrets, but the output object is built at line 274 as SettingsOutput(settings=settings.copy(), ...) before masking, and mcp_server_token is absent from the masking list. The internal API token is returned in cleartext. Link 3: POST /api/api_files_get. requires_auth is False and requires_api_key is True; the token from link 2 is the key. Its else branch assigns external_path = path and calls open(external_path, "rb") with no allowlist, so any absolute path is served. helpers/files.py:576-584 returns absolute inputs unchanged and joins relative ones without normalizing dot-dot segments. Link 4: POST /api/rfc. This endpoint declares requires_auth = False, requires_csrf = False and does not override requires_api_key, whose base default is False, so it requires no credential of any kind. Its only barrier is crypto.verify_data over the request body keyed on RFC_PASSWORD. That password is stored in .env, which link 3 reads in cleartext. Once the HMAC verifies, helpers/rfc.py:60-66 executes importlib.import_module(module) followed by getattr(imp, function_name) with no module or function allowlist, so subprocess.getoutput reaches the shell. It is possible to launch the attack remotely, with no authentication and no user interaction. The exploit has been verified end to end in a controlled environment and has been disclosed to the public. PRODUCT Vendor: Agent Zero Product: Agent Zero Repository: https://github.com/agent0ai/agent-zero Affected version: main @ 2026-11-05 Component: helpers/api.py, helpers/login.py, helpers/settings.py, api/settings_get.py, api/api_files_get.py, api/rfc.py, helpers/rfc.py CWE: CWE-306 (primary), CWE-200, CWE-78 CVSS v3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (9.8 Critical) END-TO-END VERIFICATION Performed against a service built from the upstream main branch at 2026-11-05, using the original register_api_route() plus the original handlers. No authentication header was sent at any point. [1] GET /api/csrf_token -> csrf token and runtime_id returned [2] POST /api/settings_get -> mcp_server_token = WP6RL4AjQMd0z20H [3] POST /api/api_files_get -> .env: RFC_PASSWORD=rfc_secret_abc123, OPENAI_API_KEY=... [4] POST /api/rfc -> HTTP 200, "uid=0(root) gid=0(root) groups=0(root)" Request body for link 4: {"rfc_input": "{\"module\":\"subprocess\",\"function_name\":\"getoutput\",\"args\":[\"id; hostname\"],\"kwargs\":{}}", "hash": "<HMAC-SHA256(rfc_input, RFC_PASSWORD)>"} When RFC_PASSWORD is unset, _get_rfc_password() raises and that final link fails closed. It is the one place in the chain where the implementation chose correctly. IMPACT Unauthenticated remote command execution as the process user, which is root in the shipped container. The attacker also obtains every provider API key and every credential in .env along the way. REMEDIATION 1. requires_auth must fail closed when no credentials are configured, and an initial credential must be required on first run. 2. Add mcp_server_token to the convert_out masking list alongside api_keys. 3. api_files_get needs an allowlist instead of a passthrough else branch; _resolve_path must normalize dot-dot segments and reject absolute inputs. 4. /api/rfc must require authentication, or be removed. Its docstring claims it is secured by a pre-shared key, but that key is retrievable through link 3. 5. helpers/rfc._get_function needs a module and function allowlist. 6. crypto.verify_data should use hmac.compare_digest. 7. The csrf_token origin gate must not persist arbitrary Origins into the allowlist without operator confirmation. DISCLOSURE https://github.com/ZSH402/agent-zero-unauthenticated-rce
Utente
 zsh07 (UID 101257)
Sottomissione06/11/2026 18:19 (27 giorni fa)
Moderazione03/12/2026 07:41 (27 days later)
StatoAccettato
Voce VulDB448520 [agent0ai agent-zero fino a 2.16 API Authentication Middleware autenticazione debole]
Punti20

Want to know what is going to be exploited?

We predict KEV entries!