Skip to content
File upload Write-up Intermediate

Weird Gpg Bypass

The application used GPG to verify and decrypt an uploaded upgrade bundle, but GPG's auto-detection could be fooled by a file created with the --store flag, which is a valid GPG file that requires no keys. An attacker could therefore upload a crafted bundle that passed the filter and was written to the filesystem, leading to arbitrary file write and potentially remote code execution.

Swagat Follow

Published on infosecwriteups.com

Will talk about a technique of GPG Bypass ,I discovered during one of the pentest i was doing and how i was able to use it to bypass the Filter to Gain Code Execution.

Swagat, on infosecwriteups.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 application relied on GPG's automatic detection of encrypted files instead of explicitly requiring decryption with a trusted key, allowing a keyless GPG file to pass verification.

Impact

An attacker could achieve arbitrary file write, which could lead to remote code execution by overwriting cron jobs, application files, or dropping shells in the webroot.

What the attacker needed

Access to upgrade upload feature; ability to upload a file

How it was found

  1. Generate GPG keys on one VM and encrypt a file.
  2. Try to decrypt the file on a different VM; decryption fails because the keys differ.
  3. Create a GPG file using the --store flag, which requires no keys.
  4. Pass the --store file to the application's GPG command; it is accepted and the original content is written to the specified location.

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.

GPG is a tool for encrypting and signing files. The application expected an encrypted upgrade file and used GPG to check it, but GPG can also handle unencrypted files. The author found a way to make a file that GPG accepts without any decryption key, so the check was bypassed and the file was written to disk.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

More by Swagat

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.