Write a known pattern into each sensitive location. Trigger the release of the resource or cause the desired state transition to occur. Read data back from the sensitive locations. If the reads are successful, and the data is the same as the pattern that was originally written, the test fails and the product needs to be fixed. Note that this test can likely be automated.
Sensitive Information in Resource Not Removed Before Reuse
This vulnerability occurs when a system releases a resource like memory or a file for reuse but fails to erase the sensitive data it previously contained. The old information remains accessible when…
What is CWE-226?
Real-world CVEs caused by CWE-226
-
Cryptography library does not clear heap memory before release
-
Ethernet NIC drivers do not pad frames with null bytes, leading to infoleak from malformed packets.
-
router does not clear information from DHCP packets that have been previously used
-
Products do not fully clear memory buffers when less data is stored into the buffer than previous.
-
Products do not fully clear memory buffers when less data is stored into the buffer than previous.
-
Products do not fully clear memory buffers when less data is stored into the buffer than previous.
-
Product does not clear a data structure before writing to part of it, yielding information leak of previously used memory.
-
Memory not properly cleared before reuse.
Trajeto do atacante passo a passo
- 1
This example shows how an attacker can take advantage of an incorrect state transition.
- 2
Suppose a device is transitioning from state A to state B. During state A, it can read certain private keys from the hidden fuses that are only accessible in state A but not in state B. The device reads the keys, performs operations using those keys, then transitions to state B, where those private keys should no longer be accessible.
- 3
After the transition to state B, even though the private keys are no longer accessible directly from the fuses in state B, they can be accessed indirectly by reading the memory that contains the private keys.
- 4
The following code calls realloc() on a buffer containing sensitive data:
- 5
There is an attempt to scrub the sensitive data from memory, but realloc() is used, so it could return a pointer to a different part of memory. The memory that was originally allocated for cleartext_buffer could still contain an uncleared copy of the data.
Vulnerable Other
Suppose a device is transitioning from state A to state B. During state A, it can read certain private keys from the hidden fuses that are only accessible in state A but not in state B. The device reads the keys, performs operations using those keys, then transitions to state B, where those private keys should no longer be accessible.
During the transition from A to B, the device does not scrub the memory. Secure Other
After the transition to state B, even though the private keys are no longer accessible directly from the fuses in state B, they can be accessed indirectly by reading the memory that contains the private keys.
For transition from state A to state B, remove information which should not be available once the transition is complete. How to prevent CWE-226
- Architecture and Design / Implementation During critical state transitions, information not needed in the next state should be removed or overwritten with fixed patterns (such as all 0's) or random data, before the transition to the next state.
- Architecture and Design / Implementation When releasing, de-allocating, or deleting a resource, overwrite its data and relevant metadata with fixed patterns or random data. Be cautious about complex resource types whose underlying representation might be non-contiguous or change at a low level, such as how a file might be split into different chunks on a file system, even though "logical" file positions are contiguous at the application layer. Such resource types might require invocation of special modes or APIs to tell the underlying operating system to perform the necessary clearing, such as SDelete (Secure Delete) on Windows, although the appropriate functionality might not be available at the application layer.
How to detect CWE-226
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.)
O Plexicus deteta automaticamente o CWE-226 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.
Frequently asked questions
O que é o CWE-226?
This vulnerability occurs when a system releases a resource like memory or a file for reuse but fails to erase the sensitive data it previously contained. The old information remains accessible when the resource is allocated to a new process or used in a different context.
Qual a gravidade do CWE-226?
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-226?
MITRE lists the following affected platforms: Not Technology-Specific.
Como posso prevenir o CWE-226?
During critical state transitions, information not needed in the next state should be removed or overwritten with fixed patterns (such as all 0's) or random data, before the transition to the next state. When releasing, de-allocating, or deleting a resource, overwrite its data and relevant metadata with fixed patterns or random data. Be cautious about complex resource types whose underlying representation might be non-contiguous or change at a low level, such as how a file might be split into…
Como é que o Plexicus deteta e corrige o CWE-226?
O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-226 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-226?
A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/226.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.
Weaknesses related to CWE-226
Incomplete Cleanup
This vulnerability occurs when an application fails to properly remove temporary files, data structures, or system resources after they…
Improper Cleanup on Thrown Exception
This vulnerability occurs when a program fails to properly restore its state or release resources after an exception is thrown, leaving…
finalize() Method Without super.finalize()
This vulnerability occurs when a Java class overrides the finalize() method but fails to call super.finalize() within it.
Insertion of Sensitive Information Into Sent Data
This vulnerability occurs when an application sends data to an external party, but accidentally includes sensitive information—like…
Improper Zeroization of Hardware Register
This vulnerability occurs when a hardware component fails to properly erase sensitive data from its internal registers before a new user…
Sensitive Information Uncleared Before Debug/Power State Transition
This vulnerability occurs when a device changes its power mode or enters a debug state but fails to wipe sensitive data that should become…
Insufficient or Incomplete Data Removal within Hardware Component
The product's data removal process fails to completely erase all data from hardware components, potentially leaving sensitive information…
Information Exposure through Microarchitectural State after Transient Execution
This vulnerability occurs when a CPU fails to completely erase temporary data traces left behind by speculative execution or error…
Improper Clearing of Heap Memory Before Release ('Heap Inspection')
Using realloc() to resize buffers containing secrets like passwords or keys can leave that sensitive data exposed in memory, as the…
Further reading
- MITRE — CWE-226 oficial https://cwe.mitre.org/data/definitions/226.html
- aes0_wrapper.sv https://github.com/HACK-EVENT/hackatdac21/blob/65d0ffdab7426da4509c98d62e163bcce642f651/piton/design/chip/tile/ariane/src/aes0/aes0_wrapper.sv#L84C2-L90C29
- Fix for aes0_wrapper https://github.com/HACK-EVENT/hackatdac21/blob/0034dff6852365a8c4e36590a47ea8b088d725ae/piton/design/chip/tile/ariane/src/aes0/aes0_wrapper.sv#L96C1-L102C16
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.