Array Index Underflow--http rpc
A JSON parsing routine in the epee serialisation library casts a signed character to an int before using it as an array index, so a negative value can index outside the lookup table. An attacker supplying crafted JSON could cause a crash or read unintended data.
- Triaged in 34 days
- Fixed in 11 months
- Disclosed after 19 months
Summary:
parserse_base_utils.h:197 const unsigned char tmp = isx[(int)++it]; Int type will cause the array subscript to appear negative and read wrong data, Solution: const unsigned char tmp = isx[(unsigned char)++it];
Releases Affected:
- up to date version on github
Steps To Reproduce:
[add details for how we can reproduce the issue]
#include <iostream> #include "serialization/keyvalue_serialization.h" #include "storages/portable_storage_template_helper.h" #include "storages/portable_storage_base.h"
#ifdef __cplusplus extern "C" #endif int LLVMFuzzerTestOneInput(const char *data, size_t size) { std::string s(data,size); try { epee::serialization::portable_storage ps; ps.load_from_json(s); } catch (const std::exception &e) { std::cerr << "Failed to load from binary: " << e.what() << std::endl; return 1; } return 0; }
Supporting Material/References:
- seed file attached
Impact
1.crash 2.leaking of sensitive info
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a signed char was widened to int before being used as an array index, allowing negative indices into the lookup table.
Impact
The text claims a crafted JSON input could crash the parser and may leak sensitive information.
What the attacker needed
Ability to submit JSON to the parser
The fix
The index should be cast to unsigned char before use, as the report itself suggests.
How it was found
- Build a small harness that passes input data to the portable storage JSON loader.
- Feed the harness crafted JSON input, for example from the attached seed file.
- Check whether parsing the crafted input crashes or reads incorrect data.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program reads text, it often looks up each character in a table to decide what it means. Here the character was treated as a number that can go negative, so the program could look up a slot before the start of the table, which is not valid memory. That can make the program crash or read the wrong data.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.