-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS: Remove some FPs from the hardcoded-credentials query #16417
Conversation
… key looks like a dummy password
QHelp previews: javascript/ql/src/Security/CWE-798/HardcodedCredentials.qhelpHard-coded credentialsIncluding unencrypted hard-coded authentication credentials in source code is dangerous because the credentials may be easily discovered. For example, the code may be open source, or it may be leaked or accidentally revealed, making the credentials visible to an attacker. This, in turn, might enable them to gain unauthorized access, or to obtain privileged information. RecommendationRemove hard-coded credentials, such as user names, passwords and certificates, from source code. Instead, place them in configuration files, environment variables or other data stores if necessary. If possible, store configuration files including credential data separately from the source code, in a secure location with restricted access. If the credentials are a placeholder value, make sure the value is obviously a placeholder by using a name such as ExampleThe following code example connects to an HTTP request using an hard-codes authentication header: let base64 = require('base-64');
let url = 'http://example.org/auth';
let username = 'user';
let password = 'passwd';
let headers = new Headers();
headers.append('Content-Type', 'text/json');
headers.append('Authorization', 'Basic' + base64.encode(username + ":" + password));
fetch(url, {
method:'GET',
headers: headers
})
.then(response => response.json())
.then(json => console.log(json))
.done(); Instead, user name and password can be supplied through the environment variables let base64 = require('base-64');
let url = 'http://example.org/auth';
let username = process.env.USERNAME;
let password = process.env.PASSWORD;
let headers = new Headers();
headers.append('Content-Type', 'text/json');
headers.append('Authorization', 'Basic' + base64.encode(username + ":" + password));
fetch(url, {
method:'GET',
headers: headers
})
.then(response => response.json())
.then(json => console.log(json))
.done(); ExampleThe following code example connects to a Postgres database using the const pg = require("pg");
const client = new pg.Client({
user: "bob",
host: "database.server.com",
database: "mydb",
password: "correct-horse-battery-staple",
port: 3211
});
client.connect(); Instead, user name and password can be supplied through the environment variables References
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Fixes #16360 and #16359.
Replaces #16244
I looked at what credentials-kinds we have, and I found the below (list is possibly non-exhaustive):
I changed the last two to just
user name
andpassword
.We already filtered away keys that look like dummy passwords for
password
,credentials
, andtoken
, and it seemed reasonable to just addkey
to that list.I also added a note in the QHelp with two sample passwords that we recognize as dummy-passwords.
Evaluations (nightly, default) look reasonable.
It removes keys that are obviously not meant to be actual secrets or the values are used for tests.
And performance is unaffected.