Almost every program that we run has access to the environment, so nothing stops them from curling our credentials to some nefarious server.

Why don’t we put credentials in files and then pass them to the programs that need them? Maybe coupled with some mechanism that prevents executables from reading any random file except those approved.

71 points
*
Deleted by creator
permalink
report
reply
36 points

I am not familiar with the software bubblewrap so I am just picturing your hard drives wrapped up inside your case.

permalink
report
parent
reply
29 points

That’s an old white-hat trick. If the tables drop, the wrap helps them bounce.

permalink
report
parent
reply
11 points
*
Deleted by creator
permalink
report
parent
reply
21 points
*

The environment of other processes is readable in procfs.

/proc/PID/environ

Thanks to the permissions it’s read-only, and only by the user with which the process runs, but it’s still bad, I think

permalink
report
parent
reply
7 points

Don’t all programs run as the user anyways? That changes nothing on a single user machine

permalink
report
parent
reply
15 points

A proper server should have one user per service.

permalink
report
parent
reply
4 points

Some have their own users, like gitlab

permalink
report
parent
reply
33 points

I have a rule that credentials in environment variables are to only ever be loaded as needed via some sort of secrets manager, optionally adding a wrapper script to do so transparently.

The whole point of passing secrets as environment variables is to avoid having things in files in plain and in known locations easy to scrape up by any malware.

Now we have people going full circle and slapping those into a .env file.

permalink
report
reply
4 points

But how do you authenticate to your secret manager? How do you prevent evil scripts from also doing this?

permalink
report
parent
reply
2 points

I type my password, or on the work MacBook, TouchID. I’d imagine yubikeys would do too.

permalink
report
parent
reply
1 point

You could decrypt a GPG key-based file to do that.

permalink
report
parent
reply
2 points

I’d be very thankful for an example of your setup. I’m using Bitwardern for browser-related password management, but for convenience scripts I load the credentials as env vars at login through .bash_profile 😅

permalink
report
parent
reply
4 points

Basically just have each sets of credentials in a script, and whenever you need to use something that needs a key, you source the script you need first.

Then each of those scripts are something like

export MY_API_KEY="$(bw get password whatever)"
permalink
report
parent
reply
1 point

thank you!

permalink
report
parent
reply
26 points

No no see the credentials have been towed outside the environment.

permalink
report
reply
12 points

The frontend fell off!

permalink
report
parent
reply
23 points
*
Deleted by creator
permalink
report
reply
22 points

The classic Unix user and permission system provides a solution for this.

Create a user for the app you are worried about. Make the environment variables available to that user only.

Other apps can’t read the secrets, and if the app itself gets exploited, it has access to the secrets in any case.

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

  • 7.5K

    Monthly active users

  • 6.6K

    Posts

  • 179K

    Comments