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

Security issue: Code injection due to insecure tmp file creation (Version <= 2.4.0) #288

Open
fluffysatoshi opened this issue May 3, 2024 · 0 comments

Comments

@fluffysatoshi
Copy link

fluffysatoshi commented May 3, 2024

This is fixed in Version 2.4.1 (modernized File-system Interface uses O_EXCL to create files in the tmp folder).

I would suggest adding a security note to the 2.4.1 release notes.

Details

Jansi extracts a .so library to the global temp folder to implement it's terminal features via OS-depended native code.

It actually creates to files:

  1. jansi-{random}.so.lck Lock file
  2. jansi-{random}.so library file.

Although random is a secure random string which cannot be
predicted this approach creates a race condition between step 1 and
step 2.

The exploit watches for jansi-*lck file creation in the tmp
folder.
Once this file is created, it prepares a world-writable
jansi-{random}.so to get ahead of the Jansi Java program which
itself doesn't check if this file already exists and just overwrites
it (keeping it's world-writeable permissions).

Now the exploit watches for a CLOSE_NOWRITE event of the jansi-{random}.so
file and replaces this file via a atomic rename of its own jansi.so file.

Full details and PoC

@fluffysatoshi fluffysatoshi changed the title Code injection due to insecure tmp file creation (Version <= 2.4.0) Security issue: Code injection due to insecure tmp file creation (Version <= 2.4.0) May 8, 2024
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

No branches or pull requests

1 participant