Skip to content
RCE Write-up Intermediate

Rce Via Misconfigured Ssh Log File Poisioning With Lfi Vulnerability

A web server's SSH authentication log file was made world-readable, and an existing local file inclusion flaw let the author read it. Because the SSH username is written into that log, a PHP payload placed in the username was executed through the LFI, giving command execution and a reverse shell.

Harsh Hatej Follow

Published on systemweakness.com

SSH log file in debian does not show by default, we need to install a package for ssh log file :

Harsh Hatej, on systemweakness.com

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 SSH auth log was given overly permissive permissions so the web server user could read it, and the LFI endpoint executed PHP found inside that log.

Impact

An attacker could run commands on the server and obtain a reverse shell, but only if the log permissions are misconfigured and an LFI already exists.

What the attacker needed

An LFI endpoint on the target; SSH auth log readable by web user; ability to reach SSH port

How it was found

  1. Install a syslog package so the SSH auth log exists and confirm its path.
  2. Change the log file permissions so the web user can read it.
  3. Read the log through the LFI parameter in the browser to confirm access.
  4. Send an SSH login attempt with a PHP payload as the username, using msfconsole because SSH cannot be edited in a proxy.
  5. Request the log through the LFI with a command parameter to run commands.
  6. Download netcat to the target, make it executable, and start a reverse shell.

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.

A local file inclusion (LFI) bug lets a website be tricked into reading a file from its own disk, such as a log file. If an attacker can also write text into that file, for example by using a made-up SSH username that gets logged, the website may treat that text as code and run it. Here the log file was readable by the web user because its permissions were too open, which made the trick possible.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Harsh Hatej

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.