Skip to content

Commit 97ed9ed

Browse files
committed
JS: Detect untrusted inputs in 'discussion' and 'discussion_comment' payloads
1 parent c4956a4 commit 97ed9ed

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

javascript/ql/src/experimental/Security/CWE-094/ExpressionInjection.ql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ private predicate isExternalUserControlledCommit(string context) {
6565
context.regexpMatch("\\bgithub\\s*\\.\\s*head_ref\\b")
6666
}
6767

68+
bindingset[context]
69+
private predicate isExternalUserControlledDiscussion(string context) {
70+
context.regexpMatch("\\bgithub\\s*\\.\\s*event\\s*\\.\\s*discussion\\s*\\.\\s*title\\b") or
71+
context.regexpMatch("\\bgithub\\s*\\.\\s*event\\s*\\.\\s*discussion\\s*\\.\\s*body\\b")
72+
}
73+
6874
from Actions::Run run, string context, Actions::On on
6975
where
7076
run.getAReferencedExpression() = context and
@@ -87,6 +93,9 @@ where
8793
or
8894
exists(on.getNode("pull_request_target")) and
8995
isExternalUserControlledCommit(context)
96+
or
97+
(exists(on.getNode("discussion")) or exists(on.getNode("discussion_comment"))) and
98+
isExternalUserControlledDiscussion(context)
9099
)
91100
select run,
92101
"Potential injection from the " + context +

0 commit comments

Comments
 (0)