Skip to content

Commit fa95871

Browse files
committed
JS: Add event handler sink to code injection
1 parent fd2e848 commit fa95871

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/CodeInjectionCustomizations.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,18 @@ module CodeInjection {
101101
)
102102
}
103103
}
104+
105+
/**
106+
* An event handler attribute as a code injection sink.
107+
*/
108+
class EventHandlerAttributeSink extends Sink {
109+
EventHandlerAttributeSink() {
110+
exists(DOM::AttributeDefinition def |
111+
def.getName().regexpMatch("(?i)on.+") and
112+
this = def.getValueNode() and
113+
// JSX event handlers are functions, not strings
114+
not def instanceof JSXAttribute
115+
)
116+
}
117+
}
104118
}

0 commit comments

Comments
 (0)