I am creating a new question as i now have another question which was raised from a previous answered question post.

What im trying to figure out is would this scenario be possible.

I have an anonymous FTP server with a file that we will call cred.gpg, within that encrypted file is a PDF named passwords.pdf.

Would it be possible, as its an anonymous server for someone to remove cred.gpg. Then for them to create a bogus file on their side which contains a virus named passwords.pdf and encrypt it using my public key to a file name cred.gpg.

Then upload that file to the server. Then when i go to open the file it all looks the same except when i go to open the passwords.pdf i am now infected.

Would this scenario be possible? I am thinking it is, but im not sure, i just need advice on whether this would be possible, as i may need to rethink my setup.


  • Definitely a possibility, actually.
    – d0nut
    May 2, 2016 at 19:43

2 Answers 2


It is possible, if your server accepts files uploaded by an anonymous user and if you don't provide a hash (e.g. SHA-256, SHA-512,...) in order to check that cred.gpg actually contains passwords.pdf and not evilfile.pdf.

  • Wouldn't the OP detect a problem when they go to decrypt cred.gpg? May 2, 2016 at 20:21
  • What kind of problem? If evilfile.pdf can be correctly opened by a file viewer (despite being malicious), I don't see how OP could detect something suspicious.
    – A. Darwin
    May 2, 2016 at 20:34
  • You're right. I was confused about whether symmetric or asymmetric encryption was being used. May 2, 2016 at 20:40
  • This answer is not partially correct, which means it's also partially wrong. Absent hashing, key validation is better trusted via fingerprinting
    – munkeyoto
    May 2, 2016 at 20:55

Let me answer this based on how PGP/GPG works. So you have a file for say Client X, and you are using FTP as a delivery mechanism. You want to ensure that your data is protected (encrypted) and only Client X can read it. To do so, you would be using your PGP key for signing, and they will use their key for decrypting.

You (PGP key which can be looked up on a PGP key server) --> Encrypt --> Them (decrypt)

Your PGP key generates a fingerprint which can be looked up. The key to it all is, ensuring Client X receives YOUR fingerprint to which THEY will have to verify. For example, if you list your specific key, here is how to get your fingerprint:

gpg --list-keys johndoe@mycompany
pub   dsa1024/1DBD1234 2011-10-05 [expires: 2021-10-02]
uid         [ultimate] VALIDATION (TESTING) <johndoe@mycompany>
sub   elg4096/12347B3C 2011-10-05 [expires: 2021-10-02]


gpg --fingerprint 1DBD1234
pub   dsa1024/1DBD1234 2011-10-05 [expires: 2021-10-02]
      Key fingerprint = 1234 EECF B9C4 6D0C 154A  5678 4B2B DE74 1DBD 9876
uid         [ultimate] VALIDATION (TESTING) <johndoe@mycompany>
sub   elg4096/12347B3C 2011-10-05 [expires: 2021-10-02]

You can then have Client X verify your key based on fingerprint matches. So let's see how I can get by this as an attacker. As an attacker, I have to know who the file is destined for. I would need to encrypt my malware pretending to be you. But how can I "spoof/mimic" your fingerprint? I can't. I can try to install a keystroke logger, wait for you to enter your password, steal your public and private key. If this happens, you have a lot more problems to contend with. BUT... I can generate my own PGP/GPG key pretending to be you, upload it to a GPG/PGP keyserver, sign ANYTHING pretending to be you. If the recipient does NOT verify the fingerprint, they are done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .