SSZ Union Deserialization Vulnerable to Trailing Data for Certain Variants
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- security
Direzione di ricerca
Inizia da value_deserializeFromBytes in packages/ssz/src/type/none.ts e confronta la gestione dell’intervallo iniziale e finale con il requisito di lunghezza zero della variante None. Riproduci il caso 00ff dell’issue, aggiungi la copertura per i dati finali e conferma che i payload vuoti validi vengano ancora deserializzati, mentre i payload non vuoti vengano rifiutati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When the None variant (selector 0x00) is selected, the payload should be strictly zero-length. Vulnerable implementations may parse the selector, then ignore any trailing bytes in the payload, leading to hash mismatches.
Expected behavior
The value_deserializeFromBytes method for NoneType should be updated to strictly assert that _data (specifically the range start to end) contains no bytes. If end - start is not 0, it should throw an error.
Steps to Reproduce
The value_deserializeFromBytes method for NoneType in /packages/ssz/src/type/none.ts ignores any trailing bytes when the selector is 0x00:
value_deserializeFromBytes(_data: ByteViews, _start: number): null {
return null;
}
PoC
import { NoneType, UintNumberType, UnionType } from "@chainsafe/ssz";
// Define a simple Union type: Union[None, Uint8]
// Selector 0 for NoneType, Selector 1 for Uint8
const noneType = new NoneType(); // Fixed: Removed redundant 'new'
const uint8Type = new UintNumberType(1); // Represents a uint8
const customUnionType = new UnionType([noneType, uint8Type]);
// --- PoC for Dirty Tail on None ---
// Goal: Demonstrate that @chainsafe/ssz deserializes a Union type
// with selector 0 (None) and unexpected trailing data without error.
console.log("--- Lodestar (chainsafe/ssz) PoC: Dirty Tail on None ---");
// 1. Construct a dirty input
// Selector 0x00 for NoneType, followed by a dirty byte 0xFF
const dirtyBytes = Buffer.from("00ff", "hex");
console.log(`Attempting to deserialize dirty bytes: ${dirtyBytes.toString('hex')}`);
try {
const deserialized = customUnionType.deserialize(dirtyBytes);
// If we reach here, deserialization was successful.
// Check if it's the None variant as expected.
if (deserialized.selector === 0 && deserialized.value === null) {
console.log("SUCCESS: Deserialized to None variant as expected.");
console.log("VULNERABILITY CONFIRMED: @chainsafe/ssz accepts dirty tail on None variant.");
console.log(`Deserialized value: Selector ${deserialized.selector}, Value: ${deserialized.value}`);
} else {
console.error("FAILURE: Deserialized to an unexpected value. PoC logic might need adjustment.");
console.error(`Deserialized value: Selector ${deserialized.selector}, Value: ${deserialized.value}`);
}
} catch (error: any) {
// If an error is thrown, it means the client correctly rejected the dirty input.
console.log(`Client correctly rejected dirty bytes. Not vulnerable. Error: ${error.message}`);
}
console.log("--- PoC End ---");
Output:
--- Lodestar (chainsafe/ssz) PoC: Dirty Tail on None ---
Attempting to deserialize dirty bytes: 00ff
SUCCESS: Deserialized to None variant as expected.
VULNERABILITY CONFIRMED: @chainsafe/ssz accepts dirty tail on None variant.
Deserialized value: Selector 0, Value: null
--- PoC End ---
- Lingua principale
- TypeScript
- Stelle
- 62
- Fork
- 30
- Merge medio
- 4h 37m
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ChainSafe/ssz
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
ListBasicType.serialize accepts values longer than the list limitForse già presa @kutluhaneth46 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ChainSafe/ssz#575 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
BitList deserialization with reuseBytes: true mutates the input bufferForse già presa @yinbowen-dc l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ChainSafe/ssz#559 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bitlist maxSize off by one and inconsistent progressive list default limitsForse già presa @yinbowen-dc l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ChainSafe/ssz#548 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
UintNumberType.serialize silently wraps out-of-range values (negative, NaN, overflow)Forse già presa @kutluhaneth46 l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ChainSafe/ssz
Issue simili
-
Release utils decode git output chunk by chunk, so a multi-byte character can turn into U+FFFDForse già presa @goranai l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 2 giorni
-
Task retarget keeps the old host in task scope and adds the new host in a form that matches nothingForse già presa @chaitanya0305 l’ha presa oggi. Apertabug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
BaaRai/ARTEX#652 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
compiler-explorer/compiler-explorer#9710 ·
I maintainer di solito rispondono entro 1 giorno
-
test(web): RevealArtwork's warm tests flake on CI because a 0 ms idle timeout means no deadlineApertabug effort:S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nightscout/nocturne#4556 ·
I maintainer di solito rispondono entro 1 giorno
-
sumHorizontal, maxHorizontal, minHorizontal, allHorizontal, anyHorizontal, struct and argSortBy treat strings as literals instead of column namesForse già presa @tomaionescu l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pola-rs/nodejs-polars#486 ·
I maintainer di solito rispondono entro 1 giorno