The following command works even though I really don’t think I should have permission to the key file:
$ openssl aes-256-cbc -d -pbkdf2 -in etc_backup.tar.xz.enc -out etc_backup.tar.xz -k /etc/ssl/private/etcBackup.key

I’m unable to even ascertain the existence of the key file under my normal user. I’m a member of only two groups, my own group and vboxusers.

The permissions leading up to that file:

drwxr-xr-x   1 root root 4010 Jul 31 08:01 etc
...
drwxr-xr-x 1 root root      206 Jul 14 23:52 ssl
...
drwx------ 1 root root    26 Jul 31 14:07 private
...
-rw------- 1 root root 256 Jul 31 14:07 etcBackup.key

OpenSSL isn’t setuid:

> ls -la $(which openssl)
-rwxr-xr-x 1 root root 1004768 Jul 14 23:52 /usr/bin/openssl

There don’t appear to be any ACLs related to that key file:

> sudo getfacl /etc/ssl/private/etcBackup.key
[sudo] password for root: 
getfacl: Removing leading '/' from absolute path names
# file: etc/ssl/private/etcBackup.key
# owner: root
# group: root
user::rw-
group::---
other::---

> sudo lsattr  /etc/ssl/private/etcBackup.key
---------------------- /etc/ssl/private/etcBackup.key

Finally, it’s not just the case that the original file was encrypted with an empty file:

> openssl aes-256-cbc -d -pbkdf2 -in etc_backup.tar.xz.enc -out etc_backup.tar.xz -k /etc/ssl/private/abc.key
bad decrypt
4047F634B67F0000:error:1C800064:Provider routines:ossl_cipher_unpadblock:bad decrypt:providers/implementations/ciphers/ciphercommon_block.c:124

Does anyone know what I’ve missed here?

You are viewing a single thread.
View all comments
17 points
*

On my machine at least man openssl shows that -k is for specifying the password you want to derive the key from, so in that case I think you are literally using the string /etc/ssl/private/etcBackup.key as the password. I think the flag you want is -kfile.

You can verify this by running the command in strace and seeing that there is no openat call for the file passed to -k.

Edit: metiulekm@sh.itjust.works beat me to it while I was writing out my answer :)

permalink
report
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 9.4K

    Monthly active users

  • 3.2K

    Posts

  • 37K

    Comments