T09 · Insecure Skill Coding Practices
- Location
SKILL.md:72- Finding
Incomplete Cryptographic Verification Allows Fabricated Records to Be Trusted
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 72-80
Vulnerability Type: Incomplete integrity and authenticity verification
Risk Level: MediumVulnerable Code
python import requests, hashlib, json # Verify chain integrity API = "https://certainlogic.ai/api" HEADERS = {"X-API-Key": "***"} ring = requests.get(f"{API}/ring/{hash}", headers=HEADERS).json() prev = requests.get(f"{API}/ring/{ring['metadata']['prev_hash']}", headers=HEADERS).json() assert prev['metadata']['ring_hash'] == ring['metadata']['prev_hash']Technical Analysis
The documented procedure claims to verify HMAC-SHA256 chain integrity, but it only compares two metadata values returned by the same remote API. It does not:
- Recompute an HMAC over the ring payload.
- Compare the result using a trusted verification key.
- Verify that the payload corresponds to its declared ring hash.
- Authenticate the requested ring identifier.
- Anchor the chain to a separately trusted root or checkpoint.
- Validate the complete chain or the canonical serialization of signed data.
The imported
hashlibmodule is not used, and no HMAC operation is performed. Consequently, the equality assertion proves only that two API responses are internally consistent. It does not prove that either response is authentic or untampered.Because both compared values originate from the same trust domain, a compromised or malicious API can manufacture a ring and predecessor whose fields satisfy the assertion. Transport security protects the connection to the configured endpoint but does not establish the historical authenticity of records returned by that endpoint.
Attack Path
- An attacker compromises the configured API, its backend data, or another component capable of controlling API responses.
- The attacker creates a fabricated execution ring containing manipulated agent inputs, outputs, tool calls, or audit metadata.
- T ...[truncated 1064 chars]
- Remediation
View remediation
Remediation Suggestions
- Define and publish a canonical serialization format for every field covered by the cryptographic proof.
- Recompute the payload hash locally and verify that it matches the declared ring hash.
- Perform actual authenticity verification using a separately trusted key. If clients must verify records without possessing a shared HMAC secret, use a suitable digital-signature scheme and distribute the public verification key through a trusted channel.
- Compare signatures or MAC values with a constant-time comparison function.
- Anchor verification to a trusted chain root, signed checkpoint, or independently distributed head value rather than trusting all linkage values returned by the same API.
- Validate the requested ring identifier, predecessor relationship, response schema, hash format, and all required fields before accepting a record.
- Fail closed on malformed responses, missing proofs, network errors, unexpected redirects, or verification failures.
- Avoid describing predecessor-field equality as HMAC-SHA256 verification. Clearly document the distinction between structural linkage checks and cryptographic authenticity verification.
- Keep API requests restricted to an approved HTTPS endpoint so URL misconfiguration cannot disclose the API key or search data to an unintended server.
