Code scanning in ServiceNow is not a single built-in button. ServiceNow itself does not scan your custom scripts for vulnerabilities the way a dedicated application security tool does. What people usually mean by "code scanning ServiceNow" is one of three things: scanning JavaScript and scripts stored in ServiceNow records (business rules, script includes, client scripts) for risky patterns, integrating an external static analysis (SAST) tool with ServiceNow's DevOps or pipeline features, or using ServiceNow's own platform health and code review tooling. This guide covers the practical route: exporting scripts, scanning them with an approved tool, and wiring results back into ServiceNow. Exact menu labels vary by ServiceNow release, plugin set and role, so treat the paths below as a map, not a guarantee.

What You'll Need

  • A ServiceNow instance with an account that can read script records (typically an admin or a role with read access to sys_script, sys_script_include and similar tables).
  • A static analysis tool your organization already approves, run locally or in your CI pipeline. Do not install unvetted scanners on a production instance.
  • Access to a non-production instance for testing any integration or scheduled job.
  • Optional: the DevOps plugin and a source control integration if you want scanning to run automatically on every change.
  • Agreement from your security team on what counts as a finding and who fixes it.

Step-by-Step

  1. Decide what you are scanning. Write down the record types in scope. The usual set is business rules (sys_script), script includes (sys_script_include), client scripts (sys_client_script), UI actions (sys_ui_action) and scheduled jobs (sysauto_script). Scanning everything at once produces noise; start with server-side scripts that touch data.
  2. Export the scripts. In ServiceNow, open the table list and filter to the records you need. Use the list's export option to download as CSV or XML, or use a scripted export if your team has one. Keep the export on a secured machine; scripts can contain internal hostnames and logic you do not want to leak.
  3. Extract the script bodies. The export gives you rows, not clean files. Pull the script field out of each row into individual .js files, keeping the record sys_id in the filename so you can trace a finding back to the record. A short script in your language of choice is fine for this.
  4. Run your approved scanner. Point the static analysis tool at the folder of extracted files. Use the tool's standard ruleset for JavaScript. Record the tool name, ruleset version and date so results are reproducible.
  5. Review findings, not just counts. Triage each result against the actual ServiceNow context. Many scanners flag patterns that are harmless in ServiceNow's sandboxed client scripts, and miss platform-specific risks such as unguarded GlideRecord queries or missing ACL checks. A finding is only real if you can explain the exploit path.
  6. Fix in a sub-production instance first. Make changes in a development instance, test them, then promote through your normal update set or pipeline. Never edit production scripts directly during a scan cycle.
  7. Automate the loop (optional). If you use the DevOps plugin with a Git repository, configure your CI system to run the scanner on each commit and publish results back as a status check. Keep the scanner configuration in the repository so it is versioned with the code.
  8. Track remediation. Log each confirmed finding as a task or story with the record sys_id, the rule that fired and the fix. Close it only after a re-scan of the fixed script comes back clean.

Common Mistakes

  • Assuming ServiceNow has a built-in vulnerability scanner for custom code. It does not; you must bring your own tool or use platform review features.
  • Scanning production directly with a tool that writes to the instance. Read-only exports are safer.
  • Treating every scanner alert as a bug. False positives are common when JavaScript written for the ServiceNow platform is judged by generic web rules.
  • Forgetting client scripts. They run in the browser and have different risk profiles from server-side scripts.
  • Losing the link between a finding and its record. Without the sys_id in the filename, remediation stalls.

Tips

  • Start with the highest-risk tables: script includes and business rules that run on insert or update of sensitive records.
  • Keep a baseline of known-accepted findings so new alerts stand out.
  • Pair scanning with ServiceNow's own code review practices: peer review of scripts before promotion catches logic and ACL issues a scanner will miss.
  • Store scanner config and rulesets in the same repository as your code so results are repeatable.
  • Re-scan after every platform upgrade; deprecated APIs can turn safe code into a finding.

Troubleshooting

If the export is empty, check that your role actually has read access to the table and that your filter is not excluding inactive records. If the scanner reports thousands of findings on the first run, narrow the ruleset to high-confidence security rules before widening it. If a fixed script still shows a finding, confirm you scanned the updated export and not a cached copy. If an automated pipeline step fails, check the CI logs for the scanner's exit code and confirm the repository path and credentials are correct. If results look wrong after an upgrade, re-run with the same ruleset version to rule out tool changes before blaming the platform.

Frequently Asked Questions

Does ServiceNow scan code automatically?

No. ServiceNow provides platform health, upgrade and code review tooling, but it does not run a general-purpose static analysis scan of your custom scripts. You need an external tool or a CI-integrated scanner.

Can I scan scripts without exporting them?

Only if your organization has an approved tool that connects to the instance through supported APIs. Otherwise export is the standard route, and it keeps the scan read-only.

Which script types should I scan first?

Server-side scripts that run on record changes: business rules and script includes. They have the most direct access to data and are the highest-value targets.

Are client scripts worth scanning?

Yes, but with different rules. Client scripts run in the browser, so look for unsafe DOM handling and data exposure rather than server-side query risks.

Will scanning break my instance?

Not if you export and scan offline. Only integrations that write back to the instance carry risk, which is why those should be tested in a sub-production instance first.

How often should I re-scan?

After every significant change set and after each platform upgrade at minimum. Teams with a CI pipeline typically scan on every commit.