Merge pull request #891 from xiemaisi/js/simplify-sensitive-actions

Approved by esben-semmle
This commit is contained in:
semmle-qlci
2019-02-08 14:12:47 +00:00
committed by GitHub
13 changed files with 160 additions and 118 deletions

View File

@@ -35,8 +35,7 @@ causing logged sensitive information to be stored as well.
<example>
<p>
The following example code stores user credentials (in this case, their account
name) in a cookie in plain text:
The following example code stores user credentials (in this case, their password) in a cookie in plain text:
</p>
<sample src="examples/CleartextStorage.js"/>
<p>

View File

@@ -1,8 +1,8 @@
var express = require('express');
var app = express();
app.get('/', function (req, res) {
let accountName = req.param("AccountName");
app.get('/remember-password', function (req, res) {
let pw = req.param("current_password");
// BAD: Setting a cookie value with cleartext sensitive data.
res.cookie("AccountName", accountName);
res.cookie("password", pw);
});

View File

@@ -8,8 +8,8 @@ function encrypt(text){
}
var app = express();
app.get('/', function (req, res) {
let accountName = req.param("AccountName");
app.get('/remember-password', function (req, res) {
let pw = req.param("current_password");
// GOOD: Encoding the value before setting it.
res.cookie("AccountName", encrypt(accountName));
res.cookie("password", encrypt(pw));
});