Skip to content
This repository was archived by the owner on Mar 20, 2020. It is now read-only.

Commit fcc2443

Browse files
committed
Merge branch 'hotfix/NODE-121-xpath-injection'
2 parents 0a9c988 + 57b5e98 commit fcc2443

File tree

7 files changed

+63
-4
lines changed

7 files changed

+63
-4
lines changed

lib/content/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
22
nosqlInjection: require('./nosqlInjection'),
3+
xpathInjection: require('./xpathInjection'),
34
xxe: require('./xxe')
45
};

lib/content/xpathInjection.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports.xml = `
2+
<?xml version="1.0"?>
3+
<users>
4+
<user>
5+
<username>admin</username>
6+
<password>admin</password>
7+
</user>
8+
<user>
9+
<username>user1</username>
10+
<password>123456</password>
11+
</user>
12+
<user>
13+
<username>tony</username>
14+
<password>ynot</password>
15+
</user>
16+
</users>
17+
`;

lib/routes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,13 @@ module.exports = {
9696
products: ['Protect'],
9797
inputs: ['query'],
9898
sinks: sinks.untrustedDeserialization
99+
},
100+
xpathInjection: {
101+
base: '/xpathInjection',
102+
name: 'XPath Injection',
103+
link: 'https://owasp.org/www-community/attacks/XPATH_Injection',
104+
products: ['Assess'],
105+
inputs: ['query'],
106+
sinks: sinks.xpathInjection
99107
}
100108
};

lib/sinks/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ module.exports = {
1111
unvalidatedRedirect: require('./unvalidatedRedirect'),
1212
xss: require('./xss'),
1313
xxe: require('./xxe'),
14-
untrustedDeserialization: require('./untrustedDeserialization')
14+
untrustedDeserialization: require('./untrustedDeserialization'),
15+
xpathInjection: require('./xpathInjection')
1516
};

lib/sinks/xpathInjection.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const xpath = require('xpath');
3+
const { DOMParser } = require('xmldom');
4+
const { xml } = require('../content/xpathInjection');
5+
const doc = new DOMParser().parseFromString(xml);
6+
7+
module.exports['xpath.select'] = async function select(
8+
input,
9+
{ safe = false, noop = false } = {}
10+
) {
11+
if (noop) return 'NOOP';
12+
13+
const path = safe ? encodeURIComponent(input) : input;
14+
15+
return new Promise((resolve) => {
16+
const searchString = `//user[username/text()='${path}']`;
17+
const user = xpath.select(searchString, doc).toString();
18+
resolve(user);
19+
});
20+
};

package-lock.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contrast/test-bench-utils",
3-
"version": "2.7.0",
3+
"version": "2.8.0",
44
"description": "Shared code to use in Contrast's web framework test apps.",
55
"main": "lib/index.js",
66
"scripts": {
@@ -36,7 +36,9 @@
3636
"request": "^2.88.0",
3737
"sequelize": "^5.21.1",
3838
"sql-template-strings": "^2.2.2",
39-
"superagent": "^5.0.5"
39+
"superagent": "^5.0.5",
40+
"xmldom": "^0.2.1",
41+
"xpath": "0.0.27"
4042
},
4143
"devDependencies": {
4244
"@contrast/eslint-config": "^1.0.3",

0 commit comments

Comments
 (0)