T09 · Insecure Skill Coding Practices
- Location
scripts/ari.py:50- Finding
Unrestricted API Origin Override Can Exfiltrate the ARI Bearer Credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ari.py:50-51, with credential loading atscripts/ari.py:96-112and authenticated network use atscripts/ari.py:261-278andscripts/ari.py:292-308
Vulnerability Type: Arbitrary authenticated API destination / credential exfiltration
Risk Level: MediumVulnerable Code
python def base_url(): return (os.environ.get("ARI_BASE_URL") or PROD_BASE).strip().rstrip("/")The API key may be loaded from either the environment or the protected local configuration:
python def resolve_key(): """Key only comes from ARI_API_KEY or the user configuration directory. It intentionally does not fall back to the Skill package directory: that location may be packaged, copied, or committed together with the Skill, contradicting the promise that the key is stored only in local user config. """ key = os.environ.get("ARI_API_KEY", "").strip() if key: return key path = config_path() if os.path.exists(path): try: with open(path, encoding="utf-8") as fh: key = (json.load(fh).get("api_key") or "").strip() if key: return key except (OSError, json.JSONDecodeError): pass return NoneAuthenticated JSON requests use the unrestricted origin and attach the bearer credential:
python def request_json(method, path, payload=None, params=None): query = { "method": method, "path": path, "params": {k: v for k, v in (params or {}).items() if v not in (None, "")}, "payload": payload, } url = base_url() + path if query["params"]: url += "?" + urllib.parse.urlencode(query["params"], doseq=True) data = None if payload is None else json.dumps(payload).encode("utf-8") headers = { "Authorization": "Bearer " + require_key(), ...[truncated 3993 chars]- Remediation
View remediation
Remediation Suggestions
-
Pin authenticated production requests to the expected origin:
python PROD_BASE = "https://ari.funewa.com"Do not permit ordinary production execution to override this destination.
-
If endpoint overrides are necessary for development, require an explicit development mode rather than trusting
ARI_BASE_URLalone. Development mode should be disabled in distributed packages. -
Validate overridden URLs before any credential is loaded or attached:
- Require the
httpsscheme. - Reject embedded credentials and URL fragments.
- Restrict hosts and ports to an explicit allowlist.
- Reject loopback, link-local, private-network, and unapproved public destinations unless a deliberate local-development mode is active.
- Require the
-
Bind credential use to an approved origin. Construct the request first, parse its final origin, and add the
Authorizationheader only when the origin exactly matches an approved authenticated API endpoint. -
Display the effective API origin and require explicit interactive confirmation before using credentials with a non-production development endpoint.
-
Keep
ARI_WEB_URLseparate from API authentication. Web links must never influence the destination receiving the bearer credential. -
Add automated tests confirming that:
- Unapproved hosts are rejected.
- Plaintext HTTP is rejected.
- Redirects cannot forward the
Authorizationheader to another origin. - Production commands always authenticate only to the pinned ARI origin.
-
