# VNX-933: Script loaded over plain HTTP

CWE-933 is the OWASP Top Ten 2013 Security Misconfiguration category with no code shape of its own.

| Field | Value |
|---|---|
| Rule ID | `VNX-933` |
| Severity | Medium |
| SARIF level | `warning` |
| Kind | `sast` |
| Languages | HTML, JavaScript / TypeScript, PHP, Java, C#, Ruby |
| CWE | [CWE-933](https://cwe.mitre.org/data/definitions/933.html) |
| CAPEC | [CAPEC-66](https://capec.mitre.org/data/definitions/66.html) |
| ATT&CK | [T1190](https://attack.mitre.org/techniques/T1190/) |
| CWSS vector | `CWSS:1.0/TI:M/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C` |
| Tags | `cross-origin-script-inclusion` `cwe-933` |
| Source | [`internal/sast/rules/vnx-933.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-933.rego) |

## Overview

CWE-933 is the OWASP Top Ten 2013 Security Misconfiguration category with no code shape of its own; this rule reports the concrete misconfiguration it was generated for, a page that loads executable script over plain http://, which anyone on the network path can replace with their own code. Reported: a `<script>` tag whose src is an http:// URL in HTML and server-side template files (.html, .htm, .php, .jsp, .erb, .ejs, .cshtml, .aspx, .vue, .svelte, Jinja, Twig, Handlebars and similar), with any quoting or letter case and with the src attribute on a later line of the start tag; and in JavaScript/TypeScript, an element made by document.createElement("script") whose src is set to an http:// URL a few lines later (el.src = or el.setAttribute("src", ...)). Not reported: https:// and protocol-relative or relative src values, loopback development servers (localhost, 127.0.0.1, 0.0.0.0, [::1]), http:// URLs on links, images or inside inline script code, HTML comments, test files, and script URLs assembled at run time. A tag with an integrity attribute is still reported: on an HTTPS page the browser blocks the script as mixed content, and on an HTTP page the attacker can rewrite the tag itself.

## Why this matters

A script fetched over plain HTTP can be replaced by anyone on the network path (public Wi-Fi, a compromised router, an ISP injecting content), and the replacement runs with the page's full privileges: it can read cookies, keystrokes and form data.

## What gets flagged

```
<script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
<script
    type="text/javascript"
    src="http://maps.example-cdn.com/api/js?v=3">
</script>

var s = document.createElement('script');
s.src = 'http://widgets.example-chat.com/embed.js';
```

## What is not flagged

```
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha384-..." crossorigin="anonymous"></script>
<script src="/assets/app.js"></script>
<script type="module" src="http://localhost:5173/@vite/client"></script>
<img src="http://images.example.com/logo.png">
```

## Remediation

1. Load the script over `https://` and add a Subresource Integrity `integrity` attribute.
2. Or host the script yourself and serve it from your own origin.
3. Set a Content-Security-Policy with `upgrade-insecure-requests` as a backstop.
4. For a confirmed false positive, add a `vulnetix-ignore: VNX-933` comment on the line.

## References

- [CWE-933](https://cwe.mitre.org/data/definitions/933.html)
- [MDN: Mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content)
- [MDN: Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)

## Suppressing this rule

Put a `nosec` comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file's language (`#`, `//`, `--` or `;`):

```text
# nosec vnx-933
// nosec vnx-933
```

Or record an ignore rule: `vulnetix ignore add --rule vnx-933 --reason "..."`. See [Suppressing findings](/sast/guides/suppressing-findings.md).
