Sensitive data read from GET request¶
ID: rb/sensitive-get-queryKind: problemSecurity severity: 6.5Severity: warningPrecision: highTags: - security - external/cwe/cwe-598Query suites: - ruby-code-scanning.qls - ruby-security-extended.qls - ruby-security-and-quality.qls
Click to see the query in the CodeQL repository
Sensitive information such as passwords should not be transmitted within the query string of the requested URL. Sensitive information within URLs may be logged in various locations, including the user’s browser, the web server, and any proxy servers between the two endpoints. URLs may also be displayed on-screen, bookmarked or emailed around by users. They may be disclosed to third parties via the Referer header when any off-site links are followed. Placing sensitive information into the URL therefore increases the risk that it will be captured by an attacker.
Recommendation¶
Use HTTP POST to send sensitive information as part of the request body; for example, as form data.
Example¶
The following example shows two route handlers that both receive a username and a password. The first receives this sensitive information from the query parameters of a GET request, which is transmitted in the URL. The second receives this sensitive information from the request body of a POST request.
Rails.application.routes.drawdoget"users/login",to:"#login_get"# BAD: sensitive data transmitted through query parameterspost"users/login",to:"users#login_post"# GOOD: sensitive data transmitted in the request bodyend
classUsersController<ActionController::Basedeflogin_getpassword=params[:password]authenticate_user(params[:username],password)enddeflogin_postpassword=params[:password]authenticate_user(params[:username],password)endprivatedefauthenticate_user(username,password)# ... authenticate the user hereendend
References¶
CWE:CWE-598: Use of GET Request Method with Sensitive Query Strings
PortSwigger (Burp):Password Submitted using GET Method
Common Weakness Enumeration:CWE-598.