Skip to content

knrdl/crydrv

Folders and files

NameName
Last commit message
Last commit date
Sep 23, 2024
Sep 19, 2024
Sep 13, 2024
Jan 20, 2025
Sep 13, 2024
Sep 19, 2024
Sep 19, 2024
Sep 23, 2024
Sep 23, 2024
Sep 23, 2024
Sep 19, 2024
Sep 19, 2024
Jan 13, 2025
Jan 13, 2025
Sep 23, 2024
Sep 23, 2024
Sep 19, 2024
Sep 23, 2024

Repository files navigation

cryDrv

encrypted CRUD everything web drive

  • data encryption on rest
  • CRUD REST API
  • arbitrary accounts via HTTP Basic Auth
  • client can read and write all filepaths for the current account
  • user can build custom DIY webpages
  • serve index.html for directories

Protocol

  1. Server: starts with env var secret_key being a (base64 encoded) 32-octets random key
  2. Client: sends HTTP request. No basic auth or cookie provided => must authenticate

  1. Client: sends basic auth with arbitrary username and password
  2. Server: userSalt = hkdf(secret_key, salt=username)
  3. Server: userKey = argon2id(password, salt=userSalt)
  4. Server: attach Cookie with value userKey to Client

  1. Client: GET file at path "/a/b.c"
  2. Server: filename = hkdf(userKey, salt=userSalt + path), check path is not empty
  3. Server: Serve file filename under webpath path (if it exists in filesystem)
  4. Client: POST/PUT file content at path "/a/b.c"
  5. Server: calculates filename, encrypts the file file = aes256gcm(content, userKey, nonce) and stores file under this path. file is encrypted chunkwise with a new nonce every 4MiB (plus PKCS#7 padding)
  6. Client: DELETE file at path "/a/b.c"
  7. Server: calculate filename and delete the file if it exists under this path

  1. Client: uses the Cookie (see 6.) in addition to basic auth
  2. Server: takes username from basic auth and userKey from cookie (remember filename is constructed using both username and userKey)

  1. Server-Admin: closes the registration
  2. Client: sends request with either (username, password) or (username, userKey)
  3. Server: userFingerprint = hkdf(userKey, salt=userSalt)
  4. Server: check userFingerprint is on allowlist. if not, print (username, userFingerprint) to server log. the server-admin can then add userFingerprint to the allowlist

Threat model

  • User has to trust the webserver blindly (as with all web apps)
  • Webserver doesn't have to trust the storage/backup provider (e.g. cloud)
  • Storage provider can still see file count, sizes and metadata => can guess possible file content types by size and track general activities via timestamps
  • add HTTPS for transport encryption

Setup

services:
  crydrv:
    image: ghcr.io/knrdl/crydrv:edge
    restart: always
    environment:
      - OPEN_REGISTRATION=true  # default: false
      - MIN_PASSWORD_LENGTH=16  # default: 16
    # - SECRET_KEY=...  # generated on first start
    ports:
      - 8000:8000
    volumes:
      - ./data:/www  # chown -R 1000:1000 ./data

    mem_limit: 4g
    memswap_limit: 4g

getting started: see webutils