Skip to content

Reimplementation of function at 0x80bb148 that prevents overflowing the destination buffer#104

Merged
taviso merged 1 commit into
taviso:mainfrom
dbastone:overflow-fix
Sep 4, 2022
Merged

Reimplementation of function at 0x80bb148 that prevents overflowing the destination buffer#104
taviso merged 1 commit into
taviso:mainfrom
dbastone:overflow-fix

Conversation

@dbastone

@dbastone dbastone commented Sep 4, 2022

Copy link
Copy Markdown
Contributor

Fixes #103

This replaces the vulnerable function with a version that aborts the copy if the destination buffer is full.

Adding destination length checks within process_fmt()/fmt_cell_combine() isn't enough, because the vulnerable function can apply a form of run-length decoding based on the values in the source buffer (using memdup()). This can cause the destination buffer to expand beyond the size of the source buffer. The proof-of-concept exploit does this to overflow a 1024-byte buffer with a 38-byte file.

Replacing a function without a symbol was a bit tricky (and I'm not sure if this is the best way to handle it) but it seems to work and all of the tests pass. I won't be offended if you decide to go with an entirely different approach!

…he destination buffer.

- Adds symbol FUN_80bb148 using objcopy --add-symbol
- Adds it to undefine.lst so it can be replaced
- Replaces it with a function that stops copying if the destination buffer is full.  The size is determined based on the calling function.
@taviso taviso merged commit 92738c4 into taviso:main Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exploitable Stack Overflow

2 participants