3 comments

  • evgpbfhnr1 hour ago
    &gt; I’m also intrigued by the potential that type systems have for “tagging” secrets and preventing their propagation beyond where they’re needed<p>facet (rust) allows tagging fields as sensitive so they won&#x27;t show up in logs: <a href="https:&#x2F;&#x2F;facet.rs&#x2F;guide&#x2F;attributes&#x2F;#sensitive" rel="nofollow">https:&#x2F;&#x2F;facet.rs&#x2F;guide&#x2F;attributes&#x2F;#sensitive</a><p>I&#x27;m sure other languages have equivalents but I rarely see this.. for example I was about to say serde doesn&#x27;t do it, but it looks like it&#x27;s possible with a wrapper type? <a href="https:&#x2F;&#x2F;docs.rs&#x2F;redactrs&#x2F;latest&#x2F;redactrs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;redactrs&#x2F;latest&#x2F;redactrs&#x2F;</a><p>Anyway, this kind of tagging is good, I want more!
  • chasil1 hour ago
    This article does not mention that environment variables are also visible by process in &#x2F;proc&#x2F;*&#x2F;environ (which has restrictive permissions, but is completely visible to root).<p>PuTTY has added a -pwfile option for use in ssh. If not exported, this interface is likely the best for non-key batch use. It seems much superior to sshpass.<p>The old .netrc format can be adapted for storage (which appears popular for curl), but I prefer sqlite databases, with permissions removed for all but the owner.
    • yjftsjthsd-h1 hour ago
      &gt; This article does not mention that environment variables are also visible by process in &#x2F;proc&#x2F;*&#x2F;environ (which has restrictive permissions, but is completely visible to root).<p>What <i>isn&#x27;t</i> visible to root? Maybe if you&#x27;re willing to go down a really deep rabbit hole you can play that game, but I would generally explicitly exclude root from my threat model.
    • evgpbfhnr1 hour ago
      &gt; This article does not mention that environment variables are also visible by process in &#x2F;proc&#x2F;*&#x2F;environ (which has restrictive permissions, but is completely visible to root).<p>He&#x27;s explicitly not using export, so they won&#x27;t show up there. Plain variables are not in the environment.<p>(it&#x27;s good to bring up this file as well as getting inherited by child processes though)
      • chasil1 hour ago
        I believe that unexported shell variables will be visible in &#x2F;proc&#x2F;*&#x2F;mem, so it would be prudent to overwrite then unset them as soon as reasonably possible in their usage.
        • evgpbfhnr1 hour ago
          mem, yes, definitely. I&#x27;m not sure how you can protect yourself from that (or root user using ptrace or equivalent debugging tool) though...<p>Oh, memfd_secret?<p><pre><code> The memory areas backing the file created with memfd_secret(2) are visible only to the processes that have ac‐ cess to the file descriptor. The memory region is removed from the kernel page tables and only the page tables of the processes holding the file descriptor map the corresponding physical memory. (Thus, the pages in the re‐ gion can&#x27;t be accessed by the kernel itself, so that, for example, pointers to the region can&#x27;t be passed to system calls.)</code></pre>
  • mpyne1 hour ago
    Another trick I&#x27;ve used is to use named FIFOs for commands that expect there to be files rather than stdin&#x2F;stdout. The command that spits the sensitive credential outputs to the FIFO and blocks.<p>The command that needs the sensitive credential to be input is pointed to the FIFO and reads it, and nothing is left over on disk or in the shell&#x27;s history or memory.
    • SoftTalker26 minutes ago
      I was going to mention this too, it was a pretty common approach we used in batch files. There&#x27;s a potential race condition if something else can read from the fifo after the secret is there but before the intended process consumes it, so you still need to be careful with permissions.
    • luckman2121 hour ago
      would very much like to see a small example of how to create, consume, and destroy those FIFOs...
      • stouset1 hour ago
        <a href="https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man1&#x2F;mkfifo.1.html" rel="nofollow">https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man1&#x2F;mkfifo.1.html</a><p>Pretty simple. This creates a named pipe. One end of a shell command redirects to it, one end redirects from it. rm when finished.
        • SoftTalker25 minutes ago
          In a shell script situation, you&#x27;d typically trap EXIT and ERR and remove the fifo in the handler.
        • akdev1l45 minutes ago
          You can just use process substitution<p>cat &lt;(secret-print my-secret)