Skip to content

fix(lightning): send the LNbits api key as X-Api-Key header instead of query param#208

Merged
TaprootFreak merged 1 commit into
developfrom
fix/lnbits-api-key-header
Jul 17, 2026
Merged

fix(lightning): send the LNbits api key as X-Api-Key header instead of query param#208
TaprootFreak merged 1 commit into
developfrom
fix/lnbits-api-key-header

Conversation

@Danswar

@Danswar Danswar commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Problem

Every server-side LNbits call (/lnurlp/{id}, /lnurlp/api/v1/lnurl/cb/{id}, POST /api/v1/payments, boltcards, lnurlw) passes the admin/wallet key as an ?api-key= query parameter, so the keys land in plain text in the LNbits access log on lds-lnbits-1:

GET /lnurlp/f7nf9B?api-key=dac9•••• HTTP/1.1" 200
POST /api/v1/payments?api-key=05e8•••• HTTP/1.1" 201

DFXswiss/api fixed the same pattern in DFXswiss/api#4225 (released to prod today); after that release this repo is the only remaining source of api-key= lines in the access log, and the planned key rotation is blocked until it stops being re-logged.

Change

  • httpLnBitsConfig sends the key as an X-Api-Key header (LNbits reads header and query param interchangeably) instead of a query param — this covers all call sites, since every LNbits request routes through this helper.
  • getBoltcards drops the redundant literal &api-key= from its URL; the config already carries the key.

Verification

  • npm run check (eslint + jest): 5 suites, 30 tests green.
  • After deploy: lds-lnbits-1 access log should show zero new api-key= lines → then rotate the LNbits keys (old values persist in historical logs).

…f query param

The admin/wallet keys were landing in plain text in the LNbits access log on
every lnurlp/lnurlw/payments call. LNbits reads X-Api-Key on the same
endpoints, so the key moves to the header and the boltcards URL drops its
redundant copy. Ports DFXswiss/api#4225 to this repo.
@Danswar
Danswar requested a review from TaprootFreak July 16, 2026 15:12
@TaprootFreak
TaprootFreak merged commit acfc72c into develop Jul 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants