DeepSeek Exploit Development
The pseudocode converts a hex string into bytes without checking the output buffer size, allowing a stack buffer overflow. An attacker could supply a long hex string to overwrite stack memory, potentially hijacking execution or bypassing a hash check.
medium.com
Published on medium.com
The bufonstack is likely a fixed-size buffer (e.g., 32 bytes for SHA-256), but the code allows writing up to 10,000 bytes (from a 20,000-character hex string). This enables a stack buffer overflow, which can lead to:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the loop lacks a bound on the number of bytes written to the fixed-size stack buffer, and it also fails to ensure the hex input has an even length.
Impact
An attacker could overwrite the return address to hijack execution or overwrite the calculated hash buffer to bypass the check, though modern protections like stack canaries and ASLR may limit exploitation.
What the attacker needed
Ability to supply the hex string input; knowledge of stack layout and target address
The fix
The code should limit the hex string length to twice the expected output size, check for even length, and use a safe loop condition.
How it was found
- Craft a hex string that converts to more bytes than the stack buffer can hold, padding to reach the saved return address.
- Append a target address (e.g., a malicious payload or ROP gadget) after the padding.
- Pass the crafted hex string as input to the vulnerable function.
- The loop writes beyond the buffer, overwriting critical stack data.
- When the function returns, execution is redirected to the attacker-controlled address.
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 write-up has not been written yet. The Original tab links to the source.
The code takes a long text string of hex characters and turns each pair into a byte, writing them into a small space on the stack (a temporary memory area). Because it never checks how many bytes it writes, a very long input spills over into nearby memory, which can crash the program or let an attacker change what it does next.
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.