You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constXAssign={assign: function(...args){/** * Combine object properties or concat array properties * * @param {any} acc the target or accumulator * @param {any} obj object to apply */functionapply(acc,obj){if(obj==null||typeofobj!=="object"){return// ignore non-object args}Object.keys(obj).forEach((key)=>{constvalue=obj[key]if(Array.isArray(value)){acc[key]=acc[key]&&Array.isArray(acc[key])
? acc[key].concat(value)
: value}elseif(typeofvalue==="object"){acc[key]=acc[key]||{}if(Array.isArray(acc[key])){acc[key]={}// getting overridden with an Object!apply(acc[key],value)}elseif(typeofacc[key]==="object"){apply(acc[key],value)}else{acc[key]=value}}else{acc[key]=value}})}/** * Apply merge for each object argument. */constresult={}args.forEach((obj)=>apply(result,obj))returnresult},}
I ran the following query:
/** * @name Prototype pollution * @description Using externally controlled input to set properties on the prototype of an object can lead to prototype pollution. * @severity high * @kind path-problem * @precision high * @id js/prototype-pollution * @tags external/cwe/cwe-471 external/cwe/cwe-915 */import javascript
import semmle.javascript.dataflow.TaintTracking
import semmle.javascript.security.dataflow.PrototypePollutingAssignmentCustomizations::PrototypePollutingAssignment
module Config implements DataFlow::ConfigSig{
DataFlow::FlowFeaturegetAFeature(){resultinstanceof DataFlow::FeatureHasSourceCallContext}predicateisSource(DataFlow::Nodesource){exists(Functionf|f.getName()="assign"|source.asExpr()=f.getAParameter())}predicateisSink(DataFlow::Nodesink){sinkinstanceofSink}}module Flow = TaintTracking::Global<Config>;
import Flow::PathGraph
from Flow::PathNodesource, Flow::PathNodesinkwhere Flow::flowPath(source,sink)selectsink.getNode(),source,sink,""
By providing the following additional taint steps, I managed to find the vulnerability (though this may be overly broad):
Hi @asgerf ,
my goal was to analyse a specific entry point and do global taint analysis. I was under the assumption that the above query would import all prototype pollution sink definitions.
Hi,
I would like to report a possible false negative for SNYK-JS-XASSIGN-1759314.
Relevant code:
I ran the following query:
By providing the following additional taint steps, I managed to find the vulnerability (though this may be overly broad):
The text was updated successfully, but these errors were encountered: