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
Added CommandInjectionChecker for checking for command injection (#2276)
* Add SQLInjectionValidator script for user input validation against SQL injection
* Add CommandInjectionChecker utility for detecting command injection attacks
---------
Co-authored-by: Daniel Madsen <daniel@madsen.local>
The CommandInjectionChecker is a ServiceNow Script Include designed to detect potential command injection attacks in user-supplied strings. It scans for common shell metacharacters and patterns (e.g., ;, |, &, $(), `) using regex, providing a boolean result to flag suspicious inputs. This utility enhances security in server-side automation without relying on external libraries, following ServiceNow best practices for input validation.
2
+
3
+
Example on how to use it:
4
+
5
+
var checker = new CommandInjectionChecker();
6
+
7
+
// Safe input
8
+
if (!checker.containsCommandInjection('Normal text')) {
9
+
gs.info('Input is clean.');
10
+
}
11
+
12
+
// Suspicious input
13
+
if (checker.containsCommandInjection('ls; rm -rf /')) {
0 commit comments