Know Your Ssh Algorithm To Never Miss The Lfi To Rce Win
The text explains that when exploiting a file inclusion or path traversal vulnerability, attackers often look only for the common RSA private key file, missing other key types such as DSA or ECDSA. By checking the public key file to identify the algorithm, an attacker can find the correct private key file and gain SSH access.
Often having a File Inclusion or Path Traversal, we check for private SSH keys for the unix users usually found in /home/user/.ssh/ directory. While searching for those we directly search for the private key path as /home/user/.ssh/idrsa as rsa is the most common and widely used algorithm for creating SSH keys and…
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 mistake is assuming only RSA keys exist and not enumerating other SSH key algorithms, so the correct private key file is overlooked.
Impact
An attacker could obtain an SSH private key and gain shell access to the target, but only if the key is present and readable via the file inclusion.
What the attacker needed
A file inclusion or path traversal vulnerability; SSH private key readable via the vulnerability
How it was found
- Use a file inclusion or path traversal to read the public key file at /home/user/.ssh/authorized_keys.
- Look at the start of the public key to see which algorithm is used (e.g., ecdsa-sha2-nistp256 means ECDSA).
- Read the corresponding private key file, such as /home/user/.ssh/id_ecdsa, using the same vulnerability.
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.
When a website lets you read files it shouldn't, you might find a secret key that lets you log into the server. Many people only look for the most common key file, but there are other types with different names. This post says you should first check the list of allowed keys to see which type is used, then grab the matching secret key.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.