Uh oh!
There was an error while loading. Please reload this page.
tls: fix object prototype type confusion - #14447
Conversation
There was a problem hiding this comment.
We have treated other changes like this as semver-major. Think this will cause breakage?
There was a problem hiding this comment.
It might, hard to say. It would break conn.getPeerCertificate().hasOwnProperty(k) but then again, such code is vulnerable to object manipulation now.
There was a problem hiding this comment.
Yes, but it's still technically semver-major. @nodejs/ctc ... thoughts?
There was a problem hiding this comment.
I think it should be semver-major, as currently parseCertString is documented. I would prefer otherwise.
There was a problem hiding this comment.
Then it's not semver-major for me. I'd go for semver-minor, or even patch.
There was a problem hiding this comment.
There are too many PRs interacting with this change.
refack
commented
Jul 24, 2017
There was a problem hiding this comment.
Perhaps a c.infoAccess[key] === undefined would be more efficient?
Or just save the value to a variable and use that value here and use it to skip the lookups below.
There was a problem hiding this comment.
Unlikely to matter because it's only a handful of keys (if it's set at all.) This is shorter so that's what I picked.
There was a problem hiding this comment.
Did a micro benchmark for that on TF&I. Small benefit for in
>varo={a:1,b:2,c:3,d:4,e:5}>varj=0>console.time('in');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(keyino)++j};console.timeEnd('in')in: 2614.723ms>console.time('!==');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(o[key]!==undefined)++j};console.timeEnd('!==')!==: 3160.657ms>console.time('!in');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(!(keyino))++j};console.timeEnd('!in')!in: 2842.438ms>console.time('===');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(o[key]===undefined)++j};console.timeEnd('===')===: 2884.768ms>console.time('!==');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(o[key]!==undefined)++j};console.timeEnd('!==')!==: 2999.367ms>console.time('===');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(o[key]===undefined)++j};console.timeEnd('===')===: 3113.552ms>console.time('!in');for(leti=0;i<1e8;++i){constkey=String.fromCharCode(97+(i%10));if(!(keyino))++j};console.timeEnd('!in')!in: 2679.466ms>There was a problem hiding this comment.
Can't we just do a strict comparison against undefined? parseCertString() shouldn't be returning null?
There was a problem hiding this comment.
I'm not sure I understand your question. The idea is to call parseCertString() for empty strings but not null or undefined.
bnoordhuis
commented
Jul 25, 2017
bnoordhuis
commented
Jul 27, 2017
Rebased now that #14473 landed. New CI: https://ci.nodejs.org/job/node-test-pull-request/9374/ |
addaleax
commented
Jul 30, 2017
This needs to be rebased again, sorry. |
refack
commented
Jul 30, 2017
So maybe we do need 12981 lib: save a reference to intrinsic constructs |
bnoordhuis
commented
Aug 7, 2017
bnoordhuis
commented
Aug 7, 2017
@refack Elaborate? I don't understand what that PR has to do with this PR. |
refack
commented
Aug 16, 2017
If we are worried about "prototype injection" we could save a pristine sealed copy of |
Use `Object.create(null)` for dictionary objects so that keys from certificate strings or the authorityInfoAccess field cannot conflict with Object.prototype properties.
bnoordhuis
commented
Aug 17, 2017
Aha, like that. That's actually quite clever but since this is semver-major anyway, I think I'll go for the most obvious approach for now. Maybe we can use it in a back-port to the stable branches. |
bnoordhuis
commented
Aug 17, 2017
Rebased + new CI: https://ci.nodejs.org/job/node-test-pull-request/9709/ |
BridgeAR
commented
Aug 30, 2017
Landed in 0f7c06e |
Use `Object.create(null)` for dictionary objects so that keys from certificate strings or the authorityInfoAccess field cannot conflict with Object.prototype properties. PR-URL: #14447 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Use `Object.create(null)` for dictionary objects so that keys from certificate strings or the authorityInfoAccess field cannot conflict with Object.prototype properties. PR-URL: nodejs#14447 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Use `Object.create(null)` for dictionary objects so that keys from certificate strings or the authorityInfoAccess field cannot conflict with Object.prototype properties. PR-URL: nodejs/node#14447 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Fix for #11771. Note that the other two are fixes for (arguably minor) security vulnerabilities.
I don't think core is directly affected but user applications might be susceptible to type confusion stemming from manipulating
__proto__or properties inherited fromObject.prototype.CI: https://ci.nodejs.org/job/node-test-pull-request/9320/