CWE-474 Base Rascunho

Use of Function with Inconsistent Implementations

This vulnerability occurs when code relies on a function whose behavior changes across different operating systems or versions, leading to unpredictable security risks when the software runs in an…

Definição

What is CWE-474?

This vulnerability occurs when code relies on a function whose behavior changes across different operating systems or versions, leading to unpredictable security risks when the software runs in an unexpected environment.
Functions can behave differently depending on where your code runs. These inconsistencies might involve how parameters are interpreted, what return codes mean, or whether the function even exists on a given platform. When you build or deploy software in an environment other than the one you tested in, these subtle differences can cause crashes, logic errors, or unexpected behavior that attackers might exploit. Some implementations of a function might have known security flaws, while others are safe. This means your application's security could depend entirely on the underlying system it's running on, creating a hidden risk. To avoid this, never assume a function behaves identically everywhere; always check documentation for the specific platforms you target and consider using standardized, portable alternatives where possible.
Impacto no mundo real

Real-world CVEs caused by CWE-474

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

    Identificar um caminho de código que trata input não confiável sem validação.

  2. 2

    Criar um payload que explora o comportamento inseguro — injeção, traversal, overflow ou abuso de lógica.

  3. 3

    Entregar o payload através de um pedido normal e observar a reação da aplicação.

  4. 4

    Iterar até que a resposta exponha dados, execute código do atacante ou escale privilégios.

Exemplo de código vulnerável

Vulnerable pseudo

A MITRE não publicou um exemplo de código para este CWE. O padrão abaixo é ilustrativo — consulte os Recursos para referências canónicas.

Vulnerável pseudo
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
  // Untrusted input flows directly into the sensitive sink.
  return executeUnsafe(input);
}
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-474

  • Architecture and Design / Requirements Do not accept inconsistent behavior from the API specifications when the deviant behavior increase the risk level.
Sinais de deteção

How to detect CWE-474

Automated Static Analysis High

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-474 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-474?

This vulnerability occurs when code relies on a function whose behavior changes across different operating systems or versions, leading to unpredictable security risks when the software runs in an unexpected environment.

Qual a gravidade do CWE-474?

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-474?

MITRE lists the following affected platforms: C, PHP.

Como posso prevenir o CWE-474?

Do not accept inconsistent behavior from the API specifications when the deviant behavior increase the risk level.

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

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-474 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-474?

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

Fraquezas relacionadas

Weaknesses related to CWE-474

CWE-758 Pai

Reliance on Undefined, Unspecified, or Implementation-Defined Behavior

This weakness occurs when software depends on specific behaviors of an API, data structure, or system component that are not formally…

CWE-1038 Irmão

Insecure Automated Optimizations

This vulnerability occurs when software uses automated tools to optimize code for performance or efficiency, but those optimizations…

CWE-1102 Irmão

Reliance on Machine-Dependent Data Representation

This weakness occurs when software directly depends on how a specific machine, processor, or operating system represents data in memory.…

CWE-1103 Irmão

Use of Platform-Dependent Third Party Components

This weakness occurs when software depends on third-party libraries or components that behave differently or lack support across various…

CWE-1105 Irmão

Insufficient Encapsulation of Machine-Dependent Functionality

This weakness occurs when an application relies on hardware-specific or platform-dependent features but fails to isolate that code from…

CWE-562 Irmão

Return of Stack Variable Address

This vulnerability occurs when a function returns a pointer to its own local variable. Since that variable's memory is on the stack, the…

CWE-587 Irmão

Assignment of a Fixed Address to a Pointer

This vulnerability occurs when code explicitly assigns a hardcoded memory address to a pointer, instead of using a dynamic or null value.

CWE-588 Irmão

Attempt to Access Child of a Non-structure Pointer

This vulnerability occurs when code incorrectly treats a pointer to a basic data type (like an integer) as if it points to a structured…

CWE-589 Filho

Call to Non-ubiquitous API

This vulnerability occurs when software relies on an operating system function that isn't available on all versions of the target…

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.