T09 · Insecure Skill Coding Practices
- Location
payment.py:11- Finding
Hard-Coded Billing API Credential Exposed in Source Code
- Content
View full analysis
Vulnerability Details
File Location:
payment.py:11-19
Vulnerability Type: Hard-coded secret and externally reusable API credential
Risk Level: HighVulnerable Code
python BILLING_API_URL = "https://skillpay.me" BILLING_API_KEY = "sk_f03aa8f8bbcf79f7aa11c112d904780f22e62add1464e3c41a79600a451eb1d2" SKILL_ID = "5706cbf7-c6f7-431c-99b0-752f05736f7b" SKILL_NAME = "income-lab" PRICE_PER_CALL = 0.01 # USDT HEADERS = { "X-API-Key": BILLING_API_KEY, "Content-Type": "application/json" }Technical Analysis
A live-looking billing API key is embedded directly in distributable source code and automatically placed in the
X-API-Keyheader. Any user who can download, inspect, cache, or otherwise access the Skill package can recover this credential.This implementation also conflicts with
_meta.json:12, which declaresSKILLPAY_API_KEYas the intended environment-variable source. The code does not read that variable and instead uses the exposed constant.The credential is transmitted only to the fixed HTTPS endpoint
https://skillpay.me, but TLS does not mitigate disclosure from the source package itself. The exact server-side authorization scope cannot be determined through static analysis. Consequently, the potential operations available to an attacker depend on the permissions assigned to this key by the billing provider.Attack Path
- An attacker obtains or installs the publicly distributed Skill package.
- The attacker opens
payment.pyand extractsBILLING_API_KEY. - The attacker constructs requests to the documented SkillPay billing endpoints using the stolen value in the
X-API-Keyheader. - If server-side authorization is insufficiently scoped, the attacker performs billing operations under the Skill's identity, consumes quotas, queries associated data, creates payment links, or submits unauthorized charge requests.
- Requests appear to originate from a ...[truncated 772 chars]
- Remediation
View remediation
Remediation Suggestions
-
Revoke the exposed API key immediately and issue a replacement; assume the current value is compromised.
-
Remove the literal credential from source code and repository history where feasible.
-
Load the key exclusively from the declared environment variable and fail closed when it is absent:
python BILLING_API_KEY = os.environ.get("SKILLPAY_API_KEY") if not BILLING_API_KEY: raise RuntimeError("SKILLPAY_API_KEY is required") -
Use narrowly scoped credentials that can access only the required Skill and billing operations.
-
Prefer short-lived tokens or server-mediated billing authorization over a reusable client-distributed secret.
-
Enforce server-side validation of the authenticated Skill ID, amount, user authorization, and request uniqueness.
-
Add idempotency keys to charge requests to reduce accidental or replayed duplicate charges.
-
Enable credential rotation, rate limiting, anomaly detection, and audit logging at the billing provider.
-
Add automated secret scanning to development and release pipelines.
-
Avoid logging authentication headers, complete API responses, or sensitive identifiers.
-
