Skip to content

Commit 887b0fa

Browse files
committed
Fixed security issue in U.set() and U.get().
1 parent 2fe92a6 commit 887b0fa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

changes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- added `insecure` flag into the `U.request()` method
55
- added `RESTBuilder.insecure()` method
66
- fixed security issue when parsing query arguments (reported by <https://github.com/fl4x>)
7+
- fixed security in `U.get()` and `U.set()` (reported by Agustin Gianni)
78

89
======= 3.4.8
910

utils.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -6617,12 +6617,16 @@ exports.parseTheme = function(value) {
66176617
return value === '?' ? CONF.default_theme : value;
66186618
};
66196619

6620+
66206621
exports.set = function(obj, path, value) {
66216622
var cachekey = 'S+' + path;
66226623

66236624
if (F.temporary.other[cachekey])
66246625
return F.temporary.other[cachekey](obj, value);
66256626

6627+
if ((/__proto__|constructor|prototype|eval|function|\*|\+|;|\s|\(|\)|!/).test(path))
6628+
return value;
6629+
66266630
var arr = parsepath(path);
66276631
var builder = [];
66286632

@@ -6636,12 +6640,9 @@ exports.set = function(obj, path, value) {
66366640
var ispush = v.lastIndexOf('[]') !== -1;
66376641
var a = builder.join(';') + ';var v=typeof(a)===\'function\'?a(U.get(b)):a;w' + (v[0] === '[' ? '' : '.') + (ispush ? v.replace(REGREPLACEARR, '.push(v)') : (v + '=v')) + ';return v';
66386642

6639-
if ((/__proto__|constructor|prototype|eval/).test(a))
6640-
throw new Error('Potential vulnerability');
6641-
66426643
var fn = new Function('w', 'a', 'b', a);
66436644
F.temporary.other[cachekey] = fn;
6644-
fn(obj, value, path);
6645+
return fn(obj, value, path);
66456646
};
66466647

66476648
exports.get = function(obj, path) {
@@ -6651,6 +6652,9 @@ exports.get = function(obj, path) {
66516652
if (F.temporary.other[cachekey])
66526653
return F.temporary.other[cachekey](obj);
66536654

6655+
if ((/__proto__|constructor|prototype|eval|function|\*|\+|;|\s|\(|\)|!/).test(path))
6656+
return;
6657+
66546658
var arr = parsepath(path);
66556659
var builder = [];
66566660

0 commit comments

Comments
 (0)