T09 · Insecure Skill Coding Practices
- Location
scripts/bilibili-garb-collection.sh:214- Finding
Bilibili access token exposed through the curl process command line
- Content
View full analysis
Vulnerability Details
File Location:
scripts/bilibili-garb-collection.sh:214
Vulnerability Type: Authentication token disclosure through process arguments
Risk Level: MediumVulnerable Code:
bash LOTTERY_RESPONSE=$(curl -s "https://api.bilibili.com/x/vas/dlc_act/lottery_home_detail?act_id=${ID}&lottery_id=${LOTTERY_ID}&mobi_app=iphone&platform=ios&appkey=${APPKEY}&access_key=${ACCESS_KEY}" 2>/dev/null)Technical Analysis
The script interpolates
BILI_ACCESS_KEYinto a URL passed directly as a command-line argument tocurl. Although the request uses HTTPS and targets an official Bilibili endpoint, TLS only protects the request in transit. It does not conceal the command arguments on the local system.During execution, the complete URL—including the access token—may be exposed through process inspection facilities such as
/proc/<pid>/cmdline, process-monitoring tools, audit services, diagnostic utilities, or command telemetry. URLs may also be retained by HTTP proxy or debugging infrastructure.Attack Path
- A user exports a valid token in
BILI_ACCESS_KEY. - The user invokes
bilibili-garb-collection.shfor a collection containing a lottery ID. - Line 214 starts
curlwith the token embedded in its URL argument. - While the process is active, another local process or user with sufficient process-inspection access reads the curl command line.
- The attacker extracts
access_keyfrom the captured URL. - The attacker reuses the token against Bilibili APIs until it expires or is revoked.
Exploitation depends on local process-visibility controls and timing, but repeated invocations or process-monitoring software can make collection practical.
Impact Assessment
Disclosure grants possession of the affected Bilibili access token. The exact privileges depend on the token's account scope and Bilibili's server-side authorization controls. Pote ...[truncated 266 chars]
- A user exports a valid token in
- Remediation
View remediation
Remediation Suggestions
- Do not place authentication secrets in command-line arguments.
- Prefer an API authentication method that accepts the token in an authorization header or protected request body, if supported by the endpoint.
- If Bilibili requires
access_keyas a query parameter, replace the externalcurlinvocation with an in-process HTTP client. This prevents the full URL from appearing in a separate process's argument vector. - Ensure application and proxy logs redact query parameters named
access_key,SESSDATA,csrf, andsign. - Run the script under a dedicated, least-privileged account with restrictive process-visibility controls.
- Rotate any token suspected of having been exposed.
