-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Only allow HTTP requests authorized by the committee #3427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ab38a50
21d872c
808aac1
2b4381b
d76ead9
397dc90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,15 +14,15 @@ use linera_base::prometheus_util::{ | |
| }; | ||
| use linera_base::{ | ||
| data_types::{Amount, ApplicationPermissions, BlobContent, BlockHeight, Timestamp}, | ||
| hex_debug, hex_vec_debug, http, | ||
| ensure, hex_debug, hex_vec_debug, http, | ||
| identifiers::{Account, AccountOwner, BlobId, ChainId, MessageId, Owner}, | ||
| ownership::ChainOwnership, | ||
| }; | ||
| use linera_views::{batch::Batch, context::Context, views::View}; | ||
| use oneshot::Sender; | ||
| #[cfg(with_metrics)] | ||
| use prometheus::HistogramVec; | ||
| use reqwest::{header::HeaderMap, Client}; | ||
| use reqwest::{header::HeaderMap, Client, Url}; | ||
|
|
||
| use crate::{ | ||
| system::{CreateApplicationResult, OpenChainConfig, Recipient}, | ||
|
|
@@ -379,8 +379,24 @@ where | |
| .map(|http::Header { name, value }| Ok((name.parse()?, value.try_into()?))) | ||
| .collect::<Result<HeaderMap, ExecutionError>>()?; | ||
|
|
||
| let url = Url::parse(&request.url)?; | ||
| let host = url | ||
| .host_str() | ||
| .ok_or_else(|| ExecutionError::UnauthorizedHttpRequest(url.clone()))?; | ||
|
|
||
| let (_epoch, committee) = self | ||
| .system | ||
| .current_committee() | ||
| .ok_or_else(|| ExecutionError::UnauthorizedHttpRequest(url.clone()))?; | ||
| let allowed_hosts = &committee.policy().http_request_allow_list; | ||
|
|
||
| ensure!( | ||
| allowed_hosts.contains(host), | ||
| ExecutionError::UnauthorizedHttpRequest(url) | ||
| ); | ||
|
|
||
| let response = Client::new() | ||
| .request(request.method.into(), request.url) | ||
| .request(request.method.into(), url) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we whitelist also methods?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's needed. We could make the allow list more complicated, mapping hosts to a set of allowed methods, but where do we draw the line? We could also limit headers, ports, etc. Right now I'm assuming that the allowed HTTP servers will be safe to communicated with. |
||
| .body(request.body) | ||
| .headers(headers) | ||
| .send() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.