T09 · Insecure Skill Coding Practices
- Location
scripts/netbox_api.py:48- Finding
Bearer Token Forwarding to Arbitrary Origins
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is transparent about NetBox API automation, but its helper can send a NetBox bearer token to non-NetBox URLs and can disable TLS verification.
Install only if you trust the publisher and are prepared to review or patch the helper first. Use a narrowly scoped NetBox token, avoid --token on shared systems, do not set NETBOX_INSECURE_TLS except in a controlled emergency, and require explicit confirmation before any batch PATCH or DELETE.
scripts/netbox_api.py:48Bearer Token Forwarding to Arbitrary Origins
scripts/netbox_api.py:41Optional TLS Verification Bypass Exposes NetBox Credentials and Operations
scripts/netbox_api.py:29API Token Accepted Through Process Command-Line Arguments
The request URL is ultimately influenced by untrusted environment/configuration input and the code always attaches the Bearer token before sending the request. Because absolute URLs are permitted, a caller can direct the tool to an arbitrary host and exfiltrate the NetBox API token or use the skill as a generic authenticated HTTP client, which is especially risky in an agent context.
r.add_header("Authorization", "Bearer " + TOK)
r.add_header("Content-Type", "application/json")
try:
with urllib.request.urlopen(r, context=ctx) as resp:
return resp.status, json.loads(resp.read().decode() or "null")
except urllib.error.HTTPError as e:
return e.code, json.loads(e.read().decode() or "null")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
`object_id`, `object.{name,device.name}`).
4. Assert: exactly one end is the target node, the other end is an EXPECTED
peer set (e.g. the two switch device names). Any unexpected peer → ABORT.
5. `DELETE /api/dcim/cables/{id}/` per cable; expect 200/204.
6. Read back: re-fetch interfaces, assert zero cabled interfaces in the target set.
## Gotchas seen in practice
The note explicitly documents an insecure TLS bypass via NETBOX_INSECURE_TLS=1 equivalent to curl -k, which disables certificate validation and enables man-in-the-middle interception of API traffic. Because this skill is for administrative batch changes against infrastructure systems, compromised TLS could expose credentials or permit tampering with destructive API requests and responses.
- 42U racks: U positions counted from 1; "RU 1 → 2" style docs = 2U nodes at
starting units 1, 3, 5, ….
- TLS: internal cert — the script verifies certificates by default; for
self-signed CAs export `NETBOX_INSECURE_TLS=1` (equivalent to `curl -k`).
- Keep tokens in the script/session only; do NOT write them into skill files or
reference notes (this file intentionally has none).
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
Usage:
netbox_api.py get "/api/dcim/devices/?limit=100&fields=name,rack,position"
netbox_api.py patch /api/dcim/devices/42/ '{"name":"x","position":3}'
netbox_api.py delete /api/dcim/cables/56/
netbox_api.py all "/api/dcim/interfaces/?limit=500" # follows `next`, prints JSON list
Env: NETBOX_BASE (your instance, e.g. https://netbox.example.com).
The documented NETBOX_INSECURE_TLS=1 option disables certificate validation and hostname checking, enabling man-in-the-middle interception of API traffic and the Bearer token. In a batch/agent automation skill that performs authenticated destructive actions, this weakens transport security significantly, particularly on untrusted networks.
Auth: --token *** flag, else read from ~/.config/netbox/token (chmod 600,
one token per line). Never hardcode the token in files or commits.
TLS: certificate verification ON by default. Internal/self-signed CAs:
export NETBOX_INSECURE_TLS=1 (equivalent to curl -k).
Stdout: JSON. Exit: 0 ok, 1 HTTP error, 2 usage/auth error.
Pagination: `all` follows the `next` URL from each response — never steps
The skill describes network/API automation and explicitly references running a Python script against a live NetBox instance, but it declares no permissions or allowed-tools scope. In an agent environment, that means the skill may obtain broader shell, network, or environment access than users expect, increasing the risk of unintended outbound calls, token exposure, or unauthorized modifications to infrastructure inventory.
This skill is designed to perform live NetBox write operations such as PATCH and DELETE against production inventory, but it does not prominently warn that these actions can modify or remove real infrastructure records. In an agentic workflow, the absence of an explicit destructive-action warning can cause users or downstream agents to treat the skill as informational, leading to accidental changes at scale.
This markdown file documents relocating devices, renaming them, modifying descriptions, and deleting 68 stale cables via API, all of which can affect inventory integrity and connectivity. While the procedure includes verification steps, it does not clearly warn the user at the skill-description level that these actions are destructive or may disrupt systems if performed incorrectly.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
netbox_api.py all "/api/dcim/interfaces/?limit=500" # follows `next`, prints JSON list
Env: NETBOX_BASE (your instance, e.g. https://netbox.example.com).
Auth: --token *** flag, else read from ~/.config/netbox/token (chmod 600,
one token per line). Never hardcode the token in files or commits.
TLS: certificate verification ON by default. Internal/self-signed CAs:
export NETBOX_INSECURE_TLS=1 (equivalent to curl -k).
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
netbox_api.py all "/api/dcim/interfaces/?limit=500" # follows `next`, prints JSON list
Env: NETBOX_BASE (your instance, e.g. https://netbox.example.com).
Auth: --token *** flag, else read from ~/.config/netbox/token (chmod 600,
one token per line). Never hardcode the token in files or commits.
TLS: certificate verification ON by default. Internal/self-signed CAs:
export NETBOX_INSECURE_TLS=1 (equivalent to curl -k).
url = path if path.startswith("http") else BASE + path allows any absolute URL to bypass the configured NetBox base. In combination with automatic Bearer-token attachment and all following server-provided next URLs, this expands the tool from a NetBox client into an arbitrary outbound request primitive and can leak credentials to attacker-controlled hosts.
These lines instruct the reader to PATCH devices and IP objects, including relocating devices and changing management IP assignments, which can affect system inventory integrity. The document gives procedural details but does not include a caution or warning that these are write operations that modify live NetBox data.