T09 · Insecure Skill Coding Practices
- Location
scripts/ratsinfo.py:205- Finding
Cross-Host Restriction Bypass Through Automatic HTTP Redirects
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly matches its stated civic-records purpose, but its promised same-host network boundary can be bypassed through redirects, so it should be reviewed before installation.
Install only if you are comfortable with a CLI that makes public web requests to OParl endpoints and dev.oparl.org, writes a local cache, and can create user-named PDF or calendar files. Avoid untrusted endpoints and untrusted logo PNG files until redirect handling is fixed to validate before following redirects and the logo parser has size limits.
scripts/ratsinfo.py:205Cross-Host Restriction Bypass Through Automatic HTTP Redirects
scripts/pdfreport.py:45Unbounded PNG Decompression and Memory Allocation
The declared purpose is a data-access/retrieval skill focused on reading German municipal council records through the OParl API. The actual code chunk is unrelated infrastructure for producing PDF reports. It includes PNG parsing, text wrapping, page layout, footer/header rendering, and PDF serialization to a file path. These are materially different capabilities from the declared purpose, and key declared behaviors—API access, municipal record lookup, topic filtering, committee/member lookup, or monitoring new papers—are absent. This is therefore a clear description-behavior mismatch.
The declared purpose is a user-facing skill for reading and tracking German municipal council records through OParl. This code chunk does not primarily implement that behavior; instead, it records a demo session and orchestrates integration tests. It launches mock servers, invokes a CLI repeatedly, checks healthy and broken endpoints, writes temp files, runs a test script, and captures outputs. Most notably, it includes a 'get file:///etc/passwd' command, which indicates local file retrieval behavior not reflected in the description. While some invoked commands (papers, track, watch, scan, report) are related to council-record functionality, the chunk’s actual purpose and capabilities are test/demo automation with additional filesystem and diagnostic actions, so the description does not accurately represent this code.
This code does not implement or support the declared behavior of querying or reading German municipal council records through the OParl API. Its primary purpose is quality assurance for generated PDF dossiers: validating that a PDF contains expected headings and terms. It accesses a local file path from argv, performs PDF content extraction, and exits with validation errors if expected phrases are missing. That is a materially different purpose and resource usage from the declared skill description.
The declared purpose is to access and interpret German municipal council information via the OParl API. This code does not query OParl, municipalities, committees, papers, or any civic records at all. Its primary function is unrelated: generating a demo video from a prerecorded local session transcript. It accesses local files, image rendering libraries, temporary directories, and ffmpeg for video creation, which are materially different resources and capabilities from the declared council-record lookup behavior. This is a clear description-behavior mismatch.
The code broadly aligns with the declared domain: it accesses municipal council information from OParl/RIS-style endpoints and supports papers, meetings, bodies, people, and tracking decisions. However, the code chunk shows materially broader capabilities than the description states. In particular, it can generate PDF dossier/report outputs, create ICS calendar files, and scan multiple municipality endpoints to produce comparative/market reports. Those are substantive user-facing capabilities, not merely internal implementation details. The description mentions being told about new council papers on a subject, but not calendar export, PDF generation, or bulk cross-municipality reporting. Therefore the declared description understates important actual behaviors, so this should be flagged as a mismatch.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# Only http and https. Building our own opener removes urllib's file and ftp
# handlers entirely, so a hostile endpoint cannot point links.next at
# file:///home/you/.ssh/id_rsa and have us read it back to the agent.
_OPENER = urllib.request.build_opener(
urllib.request.HTTPHandler,
urllib.request.HTTPSHandler,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# Only http and https. Building our own opener removes urllib's file and ftp
# handlers entirely, so a hostile endpoint cannot point links.next at
# file:///home/you/.ssh/id_rsa and have us read it back to the agent.
_OPENER = urllib.request.build_opener(
urllib.request.HTTPHandler,
urllib.request.HTTPSHandler,
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
R = ["python3", "scripts/ratsinfo.py"]
def town(port, name, ags):
env = dict(os.environ, MOCK_PORT=str(port), MOCK_TOWN=name, MOCK_AGS=ags)
return subprocess.Popen(["python3", "tests/mock_ris.py"], env=env)
The demo explicitly invokes the skill with file:///etc/passwd, demonstrating and validating local file read capability unrelated to the stated municipal-records purpose. In an agent environment, accepting file:// URLs can enable arbitrary local file disclosure, and /etc/passwd is a classic probe indicating filesystem access testing rather than legitimate business logic.
R + ["watch", OK, "--term", "Sanierung"],
R + ["check", BAD + "/dead"],
R + ["check", BAD + "/blocked"],
R + ["get", "file:///etc/passwd"],
R + ["scan", "--endpoints", "/tmp/eps.txt", "--term", "Sanierung",
"--pdf", "/tmp/markt.pdf", "--logo", "/tmp/aq.png", "--org",
"ALPHA QUADRAT Bauplanung und Projektmanagement"],
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
if stripped.startswith("error:") or "passed," in line and "0 failed" not in line:
return ERR
if stripped.startswith("$"):
return PROMPT
return OUT
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
MOCK_T2=$!
python3 tests/mock_broken.py &
MOCK_BAD=$!
trap 'kill $MOCK_OK $MOCK_T2 $MOCK_BAD 2>/dev/null; rm -rf "$RATSINFO_CACHE"' EXIT
sleep 1
PASS=0
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# --- the guards. each of these caught a real defect during review. ---
expect "a file:// url is refused" 2 "Only http and https" \
python3 scripts/ratsinfo.py get "file:///etc/passwd"
expect "a cross host link is not followed" 2 "not the endpoint you asked for" \
python3 scripts/ratsinfo.py check "http://127.0.0.1:8799/evil-system"
expect "--allow-cross-host lets it through" 2 "body list is empty" \
The skill advertises network access, cache/file writes, environment-variable control, and shell execution via Python, but it does not declare a constrained tool scope such as allowed tools or permissions. That increases the blast radius if the skill is invoked in a broader agent runtime, because the runtime may permit more capabilities than are necessary for the stated use case.
The documentation states that report writes a one-page PDF dossier 'in German', which imposes a specific language on generated output. The file does not indicate any user opt-in, alternative locale support, or justification as a strict region-specific compliance requirement for the output language itself.
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
such as expert reports, photographs and plans often carry third party
copyright, and paper texts routinely name private individuals who were
never public figures. A full text index of those names changes their
situation without asking them.
Read the `license` field, keep the source with every document you store,
and think before you publish. `references/recht-und-etikette.md` has the
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
def save_state(endpoint: str, kind: str, state: dict) -> None:
path = _state_path(endpoint, kind)
tmp = path + ".tmp"
with open(tmp, "w", encoding="utf-8") as handle:
json.dump(state, handle, ensure_ascii=False, indent=1)
os.replace(tmp, path) # never leave a half written state behind
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
def save_state(endpoint: str, kind: str, state: dict) -> None:
path = _state_path(endpoint, kind)
tmp = path + ".tmp"
with open(tmp, "w", encoding="utf-8") as handle:
json.dump(state, handle, ensure_ascii=False, indent=1)
os.replace(tmp, path) # never leave a half written state behind
The skill goes beyond read/query behavior by writing PDF dossiers and calendar files to arbitrary user-supplied local paths. In an agent setting, filesystem write capabilities expand the blast radius from passive data retrieval to persistent local side effects, which can overwrite files, leak queried data into artifacts, or be abused by downstream prompts to place files in sensitive locations.
The scan command performs broad multi-endpoint reconnaissance across many municipalities and can generate market-intelligence style reports, which materially exceeds the manifest’s municipality-specific lookup framing. In an agent context, this increases privacy/compliance and misuse risk because a seemingly narrow civic-records skill can be repurposed for bulk monitoring and profiling at scale.
This code declares the tool as a client for German council information systems, and several user-facing outputs and report text are hard-coded in German. The skill does not offer the user a language choice or opt-in for this locale, which matches the policy concern about forcing a specific language without user choice.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
os.environ["RATSINFO_MIN_INTERVAL"] = "0"
os.environ["RATSINFO_CACHE"] = "/tmp/ratsinfo-demo-cache"
subprocess.run(["rm", "-rf", "/tmp/ratsinfo-demo-cache"])
OK = "http://127.0.0.1:8799/system"
BAD = "http://127.0.0.1:8798"
The script deletes /tmp/ratsinfo-demo-cache with rm -rf, which is a destructive file operation. Although the module docstring describes recording a demo session, there is no specific warning, confirmation, or inline comment disclosing that the script will remove filesystem data at this path.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def town(port, name, ags):
env = dict(os.environ, MOCK_PORT=str(port), MOCK_TOWN=name, MOCK_AGS=ags)
return subprocess.Popen(["python3", "tests/mock_ris.py"], env=env)
servers = [
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
town(8799, "Stadt Musterhausen", "05124000"),
town(8801, "Stadt Beispielstadt", "05158000"),
town(8802, "Gemeinde Musterdorf", "05170032"),
subprocess.Popen(["python3", "tests/mock_broken.py"]),
]
open("/tmp/eps.txt", "w").write(
"http://127.0.0.1:8799/system\n"
The demo script intentionally exercises capabilities outside the municipal-records use case, including local file access and execution of additional scripts. In an agent-skill context, showcasing and normalizing such behavior can mask dangerous capability creep and encourages paths that could expose host data if similar functionality is reachable in production.