Skip to content

Commit

Permalink
[stable2409] Backport #5678 (#5691)
Browse files Browse the repository at this point in the history
Backport #5678 into
stable2409

Co-authored-by: ggwpez <ggwpez@users.noreply.github.com>
  • Loading branch information
niklasad1 and ggwpez committed Sep 12, 2024
1 parent 3b9bb9b commit 9330fc3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions prdoc/pr_5678.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: 'rpc server: fix deny unsafe on RpcMethods::Auto'
doc:
- audience: Node User
description: |-
Close #5677

I made a nit when I moved this code: https://github.com/paritytech/polkadot-sdk/blob/v1.14.0-rc1/substrate/client/service/src/lib.rs#L379-#L385 in https://github.com/paritytech/polkadot-sdk/pull/4792

Thus:
- (ip.is_loopback(), RpcMethods::Auto) -> allow unsafe
- (!ip.is_loopback(), RpcMethods::Auto) -> deny unsafe
crates:
- name: sc-rpc-server
bump: patch
2 changes: 1 addition & 1 deletion substrate/client/rpc-servers/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub(crate) fn get_proxy_ip<B>(req: &http::Request<B>) -> Option<IpAddr> {
/// Get the `deny_unsafe` setting based on the address and the RPC methods exposed by the interface.
pub fn deny_unsafe(addr: &SocketAddr, methods: &RpcMethods) -> DenyUnsafe {
match (addr.ip().is_loopback(), methods) {
| (_, RpcMethods::Unsafe) | (false, RpcMethods::Auto) => DenyUnsafe::No,
(_, RpcMethods::Unsafe) | (true, RpcMethods::Auto) => DenyUnsafe::No,
_ => DenyUnsafe::Yes,
}
}
Expand Down

0 comments on commit 9330fc3

Please sign in to comment.