{"id":2305,"cve":"CVE-2026-81662","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-81662\/","cwe":"CWE-20","cwe_number":20,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/20","cvss_score":8.6,"published":"2026-08-27","owasp":"A03 Injection","odc":"Assignment","cdc":"Incorrect Assignment","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Code injection via untrusted config keys in Flowintel alert settings update endpoint.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-81662\/","description":"Affected versions of Flowintel improperly trust configuration keys supplied to the alerts settings update endpoint. While configuration values were normalized to Python literals, the corresponding keys were used directly when constructing and replacing lines in conf\/config_module.py.   The vulnerable code used requester-controlled keys in both the regular expression and the generated assignment:   f'{key} = {py_val}'  and appended an assignment if the key was not already present. The modified Python configuration module was subsequently reloaded using importlib.reload(). This creates a code-generation boundary in which specially crafted configuration keys can alter the Python source structure and result in execution of attacker-controlled Python statements.   Version impacted >=3.3.0","solution":"Upgrade Flowintel to v3.4.0 (or later), where the configuration\u2011key handling in the alerts settings endpoint is properly sanitized.","affected_component":"Python 3.3.0","fixed_by_upgrading":false,"vulnerable_code":"import importlib\nimport ast\nimport os\n\nCONFIG_PATH = os.path.join(os.path.dirname(__file__), 'conf', 'config_module.py')\n\n\ndef update_alerts_settings(updates: dict):\n    \"\"\"\n    Apply a dict of configuration updates to conf\/config_module.py.\n    \"\"\"\n    # Load current file\n    with open(CONFIG_PATH, 'r') as f:\n        lines = f.readlines()\n\n    # Build a mapping of existing keys to line numbers\n    existing = {}\n    for idx, line in enumerate(lines):\n        if line.strip() and not line.lstrip().startswith('#'):\n            parts = line.split('=', 1)\n            if len(parts) == 2:\n                existing[parts[0].strip()] = idx\n\n    # Apply updates\n    for key, val in updates.items():\n        py_val = ast.literal_eval(repr(val))  # normalize to Python literal\n        # VULNERABLE: directly interpolates untrusted key into code\n        assignment = f'{key} = {py_val}\\n'\n        if key in existing:\n            lines[existing[key]] = assignment\n        else:\n            lines.append(assignment)\n\n    # Write back the modified module\n    with open(CONFIG_PATH, 'w') as f:\n        f.writelines(lines)\n\n    # Reload the module so changes take effect\n    import conf.config_module as cfg\n    importlib.reload(cfg)\n","patched_code":"import importlib\nimport ast\nimport os\nimport re\n\nCONFIG_PATH = os.path.join(os.path.dirname(__file__), 'conf', 'config_module.py')\n# Allow only alphanumeric identifiers and underscores for config keys\n_KEY_PATTERN = re.compile(r'^[A-Za-z_][A-Za-z0-9_]*$')\n\n\ndef update_alerts_settings(updates: dict):\n    \"\"\"\n    Apply a dict of configuration updates to conf\/config_module.py.\n    \"\"\"\n    with open(CONFIG_PATH, 'r') as f:\n        lines = f.readlines()\n\n    existing = {}\n    for idx, line in enumerate(lines):\n        if line.strip() and not line.lstrip().startswith('#'):\n            parts = line.split('=', 1)\n            if len(parts) == 2:\n                existing[parts[0].strip()] = idx\n\n    for key, val in updates.items():\n        if not _KEY_PATTERN.match(key):\n            # FIX: reject keys that are not valid Python identifiers\n            raise ValueError(f'Invalid configuration key: {key}')\n        py_val = ast.literal_eval(repr(val))\n        # FIX: safely construct assignment using a validated key\n        assignment = f'{key} = {py_val}\\n'\n        if key in existing:\n            lines[existing[key]] = assignment\n        else:\n            lines.append(assignment)\n\n    with open(CONFIG_PATH, 'w') as f:\n        f.writelines(lines)\n\n    import conf.config_module as cfg\n    importlib.reload(cfg)\n","payload_needed":true,"payload":null,"payload_status":"model_refused","published_fix":[{"repository":"flowintel\/flowintel","commit_url":"https:\/\/github.com\/flowintel\/flowintel\/commit\/d36171e22aed99055539260bec75e6355ada7d0c","commit_subject":"fix: [security] Remote code execution through settings alerts config","units":[{"file":"app\/alerts\/alerts.py","function":null},{"file":"app\/alerts\/alerts.py","function":"update_config"}]}],"references":null}