Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploitable Stack Overflow #103

Closed
dbastone opened this issue Sep 4, 2022 · 6 comments · Fixed by #104
Closed

Exploitable Stack Overflow #103

dbastone opened this issue Sep 4, 2022 · 6 comments · Fixed by #104

Comments

@dbastone
Copy link
Contributor

dbastone commented Sep 4, 2022

The unnamed function at 0x80bb148 is used to copy data into a buffer and lacks a destination length check. This function is called in two places - by process_fmt() and fmt_cell_combine(). The call by process_fmt() is reachable using a w3r_format element (0x13) in a wk3 file, where user-controlled data from the file is copied into a stack variable. The call by fmt_cell_combine() was not investigated.

ushort process_fmt(byte *buf,ushort buflen,ushort param_3)
{
[...]
  char local_404 [1024];
[...]
    uVar3 = FUN_080bb148(local_404,buf + 4,buflen - 4);
                           dst       src     len

Both buf and buflen are controllable. The included exploit demonstrates this by overwriting the return address to point to a jmp esp gadget, where the payload causes the process to exit with a return value of 3 (I had originally intended to submit this to BGGP3, but missed the deadline!)

A pull request will be provided containing a proposed fix.

Base64 encoded exploit.wk3 - AAAFAAAQBAAREwAVAAAAAAD+/v7+/zMzMzO8yhIIQM2AMw==
[edit: reduced exploit size from 38 to 34 bytes]

This was discovered using Ghidra and AFL++'s QEMU mode, and was inspired by this tweet.

@taviso
Copy link
Owner

taviso commented Sep 4, 2022

This is incredible, thank you for the thorough bug report!

I'm away from my workstation until the morning, I'll build a new release tomorrow. I think there should also be an advisory to commemorate, this has to be some sort of record 😂

taviso added a commit that referenced this issue Sep 4, 2022
@taviso
Copy link
Owner

taviso commented Sep 4, 2022

I've confirmed everything you've said. I think the __builtin_return_address() solution is clever, but maybe just capping it at 256 will work... at least all the tests seem to pass, and it's a bit cleaner 🤷‍♂️

I guess I'll try that and see if something breaks.

Everything else looks good to me, I'll build a new release.

I think I'll send an advisory, let's see if mitre will assign a CVE lol

@dbastone
Copy link
Contributor Author

dbastone commented Sep 5, 2022

Sounds good, thank you!

@taviso
Copy link
Owner

taviso commented Sep 5, 2022

All done. Thank you so much... and a quality patch and exploit, impressive and hilarious 😆

@taviso
Copy link
Owner

taviso commented Sep 5, 2022

123ADV-001: Stack Buffer Overflow in Lotus 1-2-3 R3 for UNIX/Linux

About

The 123 command is a spreadsheet application for UNIX-based systems that can
be used in interactive mode to create and modify financial and scientific
models.

For more information, see https://123r3.net

Advisory

A stack buffer overflow was reported in the cell format processing routines. If
a victim opens an untrusted malicious worksheet, code execution could occur.
This vulnerability has been resolved by adding additional bounds checks.

There have been no reports of this vulnerability being exploited in the wild.

We take your security very seriously, in fact, this is the first known
vulnerability reported in Lotus 1-2-3 R3 since it's release in September 1990.

Credit

This issue was reported to the 123elf project by @dbastone.

Solution

A new release has been prepared to resolve this issue, we recommend affected
users upgrade urgently.

https://github.com/taviso/123elf/releases

Lotus 1-2-3 releases for other platforms are affected, but are not actively
maintained. Users are advised to migrate to Linux to continue receiving
updates.

@poinine
Copy link

poinine commented Sep 11, 2022

:d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants