T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/bambu.sh:18
- Finding
- Hardcoded Printer Credentials Expose MQTT Control Access<![CDATA[ ## Vulnerability Details **File Location**: `scripts/bambu.sh:18-22`; duplicated in `scripts/bambu.py:20-24`, `scripts/bambu_monitor.py:20-24`, `SKILL.md:13-17`, `README.md:31-35`, and `references/mqtt.md:7-8` **Vulnerability Type**: Hardcoded credentials **Risk Level**: High ### Vulnerable Code ```bash # Konfiguration HOST="${BAMBU_HOST:-192.168.30.103}" PORT="${BAMBU_PORT:-8883}" SERIAL="${BAMBU_SERIAL:-03919A3A2200009}" ACCESS_CODE="${BAMBU_ACCESS_CODE:-33576961}" MODEL="${BAMBU_MODEL:-A1}" ``` The Python implementations contain equivalent hardcoded values: ```python HOST = "192.168.30.103" PORT = 8883 SERIAL = "03919A3A2200009" ACCESS_CODE = "33576961" MODEL = "A1" ``` ### Technical Analysis The project commits an apparently operational printer serial number, LAN address, and access code to source control and documentation. The serial number is used as the MQTT username, while the access code is used as the password. Although the shell implementation permits environment-variable overrides, the exposed values remain active defaults. The Python implementations do not provide environment-variable overrides and always use the committed credentials. Printer control messages are published to `device/<serial>/request`. Consequently, an individual who obtains the project and can reach the printer network has all information required to attempt MQTT authentication and issue printer commands. ### Attack Path 1. An attacker obtains a copy of the repository or a distributed Skill package. 2. The attacker extracts the printer IP address, serial number, and access code. 3. The attacker gains connectivity to the same LAN, VPN, or another network route exposing port 8883. 4. The attacker authenticates to the printer's MQTT service using the serial number and access code. 5. The attacker publishes supported commands to `device/03919A3A2200009/request`. 6. The attacker reads operational reports or issues actions such as pause, resume, stop, light control, ...[truncated 599 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Immediately rotate the exposed printer LAN access code. 2. Remove all real addresses, serial numbers, chat identifiers, and access codes from source code and documentation. 3. Require credentials through environment variables or a permission-restricted configuration file: ```bash : "${BAMBU_HOST:?BAMBU_HOST must be set}" : "${BAMBU_SERIAL:?BAMBU_SERIAL must be set}" : "${BAMBU_ACCESS_CODE:?BAMBU_ACCESS_CODE must be set}" ``` 4. Apply equivalent mandatory configuration handling to both Python scripts: ```python HOST = os.environ["BAMBU_HOST"] SERIAL = os.environ["BAMBU_SERIAL"] ACCESS_CODE = os.environ["BAMBU_ACCESS_CODE"] ``` 5. Replace documentation values with unmistakable placeholders such as `PRINTER_IP`, `PRINTER_SERIAL`, and `PRINTER_ACCESS_CODE`. 6. Store local secrets in a file excluded from version control and restrict it to the service account, such as mode `0600`. 7. Review repository history and distributed artifacts for prior copies of the credentials. 8. Restrict MQTT port 8883 at the network layer to specifically authorized management hosts. ]]>
