T09 · Insecure Skill Coding Practices
- Location
references/endpoint-index.md:302- Finding
OAuth Client Secrets and Refresh Tokens May Be Placed in URL Query Strings
- Content
View full analysis
Vulnerability Details
File Location:
references/endpoint-index.md:302-303, used with the parameter-mapping instructions inreferences/example-patterns.md:11-15
Vulnerability Type: Sensitive information exposure through URL query parameters
Risk Level: MediumVulnerable Code Snippets
references/endpoint-index.md:302-303:markdown - `POST /api/login/oauth/access_token` — get OAuth access token (params: grant_type:query, client_id:query, client_secret:query, ...) - `POST /api/login/oauth/refresh_token` — refresh OAuth access token (params: grant_type:query, refresh_token:query, scope:query, ...)references/example-patterns.md:11-15:markdown - Path parameters stay in the URL path. - Query parameters go in the query string and should only include values the user actually supplied. - Body parameters should be serialized as JSON unless the Swagger operation states another content type. - Header values such as bearer tokens should use placeholders like `<access-token>` when not provided.Technical Analysis
The endpoint index classifies
client_secretandrefresh_tokenas query parameters. The example-generation rules then explicitly instruct the agent to place all parameters classified asqueryinto the URL query string.Consequently, generated OAuth requests may take forms equivalent to:
text POST /api/login/oauth/access_token?...&client_secret=REAL_SECRET POST /api/login/oauth/refresh_token?...&refresh_token=REAL_REFRESH_TOKENAlthough transmitting credentials to the intended Casdoor token endpoint is necessary for the declared functionality, placing them in a URL exceeds the minimum exposure required. OAuth credentials should normally be sent in the request body using
application/x-www-form-urlencoded, or through another authentication mechanism explicitly supported by the deployment. HTTPS protects the request while in transit but does not prevent URL disclosure through:- Reverse-proxy, ingress, ...[truncated 2188 chars]
- Remediation
View remediation
Remediation Suggestions
- Override the imported endpoint metadata for OAuth token operations so that
client_secretandrefresh_tokenare treated as form-body parameters rather than query parameters. - Generate token requests using
Content-Type: application/x-www-form-urlencoded, for example:
bash curl -X POST 'https://<casdoor-host>/api/login/oauth/access_token' \ -H 'Accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=<grant-type>' \ --data-urlencode 'client_id=<client-id>' \ --data-urlencode 'client_secret=<client-secret>'- Add an explicit safety rule to
references/example-patterns.md: passwords, client secrets, authorization codes, access tokens, and refresh tokens must not be placed in URL paths or query strings, even if generated Swagger metadata classifies them as query parameters. - Use placeholders by default and avoid reproducing real credentials supplied in conversation. Instruct users to inject secrets through environment variables, protected secret stores, or interactive input.
- Redact sensitive values from displayed commands, debugging output, logs, and error reports.
- If a particular Casdoor version accepts credentials only in the query string, clearly warn the user about logging exposure, recommend upgrading or changing server configuration, and avoid presenting that mode as the default.
- Add regression tests or review checks ensuring generated URLs never contain parameter names such as
client_secret,refresh_token,password,access_token, or authorization codes. - Rotate any credential that has already appeared in a URL or associated operational logs, and purge or restrict access to affected logs where feasible.
- Override the imported endpoint metadata for OAuth token operations so that
