Posibble Bug: Stack Buffer Underflow in `tinyxml2::XMLPrinter::PrepareForNewNode(bool)`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 15/100
Direzione di ricerca
The report points at XMLPrinter::PrepareForNewNode near line 2739 of tinyxml2.cpp, but the fuzz driver only exercises StrPair (SetStr, Reset, Empty), so first check whether that code path can reach the printer at all. Build with AddressSanitizer and run the driver on the reported input to see if the underflow reproduces. Done means either a reproducer that actually hits PrepareForNewNode with a fix, or a documented finding that the report is not reproducible.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🐞 Bug Report: Stack Buffer Underflow in tinyxml2::XMLPrinter::PrepareForNewNode(bool)
🔤 Summary
A stack buffer underflow vulnerability was detected in the function tinyxml2::XMLPrinter::PrepareForNewNode(bool) located in tinyxml2.cpp at line 2739. The issue occurs when reading from an invalid memory address on the stack, potentially leading to information leakage or arbitrary code execution.
📍 Location
- File:
tinyxml2.cpp - Function:
tinyxml2::XMLPrinter::PrepareForNewNode(bool) - Line: 2739
🧪 Reproduction Steps
This issue was triggered using the following fuzzing test driver:
extern "C" int LLVMFuzzerTestOneInput_0(const uint8_t *fuzz_data, size_t fuzz_size) {
FuzzedDataProvider provider(fuzz_data, fuzz_size);
std::string tmp_string_content_0 = provider.ConsumeRandomLengthString();
const char* string_content_0 = tmp_string_content_0.c_str();
StrPair strPair;
strPair.SetStr(string_content_0);
strPair.Reset();
strPair.Empty();
return 0;
}
Although this test case does not directly invoke XML printing functionality, it indirectly leads to a call to PrepareForNewNode() through internal XML processing logic.
🧠 Root Cause Analysis
The function PrepareForNewNode() performs a read operation that accesses memory outside the valid stack frame:
void XMLPrinter::PrepareForNewNode( bool compactMode )
{
SealElementIfJustOpened();
if ( compactMode ) {
return;
}
if ( _firstElement ) {
PrintSpace (_depth); // ← Possible out-of-bounds access here
} else if ( _textDepth < 0 ) {
Putc( '\n' );
PrintSpace( _depth );
}
_firstElement = false;
}
The problem occurs inside the call to PrintSpace(_depth), where _depth may be used to calculate an invalid offset on the stack buffer. AddressSanitizer reports a stack-buffer-underflow , indicating that the code reads before the start of a local variable's allocated space.
This is likely due to incorrect bounds checking or improper handling of _depth when computing indentation spaces.
🚨 ASan Error Output
==2875063==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7ffce45545b8
READ of size 4 at 0x7ffce45545b8 thread T0
#0 0x55bef7268b8d in tinyxml2::XMLPrinter::PrepareForNewNode(bool)
...
SUMMARY: AddressSanitizer: stack-buffer-underflow /data/cpput_vol/utscript/projects/tinyxml2/tinyxml2_4/tinyxml2.cpp:2739
AddressSanitizer confirms that the read access occurred before the beginning of a local stack object.
- Lingua principale
- C++
- Stelle
- 5.8k
- Fork
- 2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 leethomason/tinyxml2
-
XMLNode::InsertAfterChild dereferences NULL when addThis is already afterThis's next siblingForse già presa @zhouyunding l’ha presa 18 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
leethomason/tinyxml2#1101 ·
-
CDATA output containing ]]> is not well-formed XMLForse già presa @bconnnnn l’ha presa 29 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
leethomason/tinyxml2#1097 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
leethomason/tinyxml2#923 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
leethomason/tinyxml2#914 ·
-
New release requestAperta
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 15/100
leethomason/tinyxml2#1087 · 4 commenti ·
Tutte le issue di leethomason/tinyxml2
Issue simili
-
[yugabyted] xcluster set_up and add_to_replication fail for database names containing - . or (Apertakind/bug priority/medium qa_automation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
yugabyte/yugabyte-db#37324 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
CharlotteCross1998/awesome-game-decompilations#61 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
godotengine/godot#125240 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
new issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
llvm/llvm-project#240065 ·
I maintainer di solito rispondono entro 1 giorno