Skip to content
This repository was archived by the owner on Jul 23, 2023. It is now read-only.
This repository was archived by the owner on Jul 23, 2023. It is now read-only.

Improve security around access keys #11

@Legogris

Description

@Legogris

To summarize my understanding of sparkos auth:

  • user/password for http basic auth: Configured via sparko-login=user:pass
  • master access key via X-Access header, URL query param: deterministic hmac from sparko-login
  • Cookie auth: contains sparko=login, ttl 30d
  • additional keys, set in cleartext via sparko-keys=[secret: [permission, ];]

The problems with this approach:

  • Secrets need to be set in cleartext in configuration, and kept in memory during the lifetime of the process
  • The access key needs to either be fetched from the running instance (via logs) or derived separately by the user form credentials

Since keys can give full control to a users lightning wallet and instance, I think it's important to minimize the exposure of these.

One can of course come up with more elaborate schemes, but here's one less-effort solution that could mitigate this:

  • Reuse bitcoind's approach with auth cookies: https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py for both user/password and additional keys
    • This is similar to the current implementation for the access key in sparko, but instead of setting the secret in config and generate the hmac at runtime, sparko would be configured with the hmac (generated with e.g. the above tool by the operator), and then validate that towards user input at validation time

IMO this is an easy mean to significantly reduce the exposure of credentials in memory and on disk.

If you agree I could take a stab at an implementation @fiatjaf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions