about summary refs log tree commit diff
path: root/src/libexpr/eval.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-07-20T18·10+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-07-20T18·10+0000
commitb2027f70d992bd2d088e71ee5cea7637445766f9 (patch)
treeb7338ce0a9d994378f9cc6a9557d1df63bd9f5d3 /src/libexpr/eval.hh
parentd2bfe1b071d0d71bb981535a53e9c5de43aaac81 (diff)
* Fix a huuuuge security hole in the Nix daemon. It didn't check that
  derivations added to the store by clients have "correct" output
  paths (meaning that the output paths are computed by hashing the
  derivation according to a certain algorithm).  This means that a
  malicious user could craft a special .drv file to build *any*
  desired path in the store with any desired contents (so long as the
  path doesn't already exist).  Then the attacker just needs to wait
  for a victim to come along and install the compromised path.

  For instance, if Alice (the attacker) knows that the latest Firefox
  derivation in Nixpkgs produces the path

    /nix/store/1a5nyfd4ajxbyy97r1fslhgrv70gj8a7-firefox-5.0.1

  then (provided this path doesn't already exist) she can craft a .drv
  file that creates that path (i.e., has it as one of its outputs),
  add it to the store using "nix-store --add", and build it with
  "nix-store -r".  So the fake .drv could write a Trojan to the
  Firefox path.  Then, if user Bob (the victim) comes along and does

    $ nix-env -i firefox
    $ firefox

  he executes the Trojan injected by Alice.

  The fix is to have the Nix daemon verify that derivation outputs are
  correct (in addValidPath()).  This required some refactoring to move
  the hash computation code to libstore.

Diffstat (limited to 'src/libexpr/eval.hh')
-rw-r--r--src/libexpr/eval.hh4
1 files changed, 0 insertions, 4 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 7453ac189197..7b7fea934501 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -188,8 +188,6 @@ void mkPath(Value & v, const char * s);
 void copyContext(const Value & v, PathSet & context);
 
 
-typedef std::map<Path, Hash> DrvHashes;
-
 /* Cache for calls to addToStore(); maps source paths to the store
    paths. */
 typedef std::map<Path, Path> SrcToStore;
@@ -203,8 +201,6 @@ std::ostream & operator << (std::ostream & str, const Value & v);
 class EvalState 
 {
 public:
-    DrvHashes drvHashes; /* normalised derivation hashes */
-
     SymbolTable symbols;
 
     const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName,