Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lnurl_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ impl LnurlAuth {

let domain = url.base_url();

// Enforce HTTPS for non-localhost URLs per LNURL spec.
let is_localhost = domain == "localhost" || domain == "127.0.0.1" || domain == "[::1]";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, but I do wonder if we should limit access to localhost/local network in general? Otherwise someone could prompt us to authenticate but have us make requests to arbitrary hosts, no? Maybe this method should take an expected hostname and abort if the decoded LNURL auth doesn't match that?

if url.scheme() != "https" && !is_localhost {
log_error!(self.logger, "LNURL-auth URL must use HTTPS for non-localhost domains");
return Err(Error::InvalidLnurl);
}

// get query parameters for k1 and tag
let query_params: std::collections::HashMap<_, _> = url.query_pairs().collect();

Expand Down Expand Up @@ -135,7 +142,7 @@ impl LnurlAuth {
let auth_url = format!("{lnurl_auth_url}&sig={signature}&key={linking_public_key}");

log_debug!(self.logger, "Submitting LNURL-auth response");
let request = bitreq::get(&auth_url);
let request = bitreq::get(&auth_url).with_max_redirects(0);
let auth_response = self.client.send_async(request).await.map_err(|e| {
log_error!(self.logger, "Failed to submit LNURL-auth response: {e}");
Error::LnurlAuthFailed
Expand Down
Loading