Invalid URL format in TcpListener binding prevents REST API from starting
The MovementRest service's default URL includes the http:// scheme, but the TcpListener::bind method expects a host:port socket address, so binding fails and the REST API cannot start. An attacker could not exploit this directly, but the service would be unavailable in production, making all API endpoints inaccessible.
A bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk
RPC API crash affecting programs with greater than or equal to 25% of the market capitalization on top of the respective layer
Description
Brief/Intro
MovementRest service fails to start because the URL provided for binding the TCP listener includes the http:// scheme. The poem::listener::TcpListener::bind() method, which is used to bind the service to a network address, expects a socket address in the format "host:port" and not a full URL. This prevents the entire REST API service from starting in any production environment, rendering all API endpoints inaccessible. Any operation built on top of Movement that rely on this REST API would be completely non-functional.
Vulnerability Details
The issue is in the MovementRest::try_from_env() method where the default URL for the service is defined, and in the run_service() method where this URL is used to bind the TcpListener.
In MovementRest::try_from_env():
Rust
let url = env::var(Self::MOVEMENT_REST_ENV_VAR)
.unwrap_or_else(|_| "http://0.0.0.0:30832".to_string());
The default value for the url field is set to "http://0.0.0.0:30832", which includes the "http://" scheme.
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<TcpListener>
Creates a new TcpListener which will be bound to the specified address.
The address type can be any implementor of ToSocketAddrs trait. See the doc for concrete examples.
Examples
Creates a TCP listener bound to 127.0.0.1:80:
use std::net::TcpListener;
let listener = TcpListener::bind("127.0.0.1:80").unwrap();
The doc and examples clearly show that TcpListener::bind() expects a string representing a socket address in the format "host:port". Passing a full URL with a scheme like "http://" will cause the binding process to fail as it cannot be parsed into a valid socket address. This will result in an error at runtime, preventing the MovementRest service from starting and listening for incoming connections.
This is a bit tricky because iff we look at the test here, the unit tests pass successfully. This is because the tests use TestClient, which doesn't actually bind to a TCP port:
Rust
#[tokio::test]
async fn test_health_endpoint() {
let rest_service = MovementRest::try_from_env().expect("Failed to create MovementRest");
assert_eq!(rest_service.url, "http://0.0.0.0:30832");
// Create a test client
let client = TestClient::new(rest_service.create_routes());
// Test the /health endpoint
let response = client.get("/health").send().await;
assert!(response.0.status().is_success());
}
}
Impact Details
I categorised this under "RPC API crash affecting programs with greater than or equal to 25% of the market capitalization on top of the respective layer" for the following reasons:
The REST service would fail to start in any production environment making all API endpoints inaccessible, including:
The /health endpoint for monitoring
The /movement/v1/state-root-hash/:blockheight endpoint for retrieving state root hashes
Any applications, wallets, or services built on top of Movement that rely on this REST API would be completely non-functional.
Build and run the Movement REST service in a real environment (not a test environment):
Rust
// This would fail with an error like:
// Error: failed to parse socket address: invalid socket address syntax
let rest_service = MovementRest::try_from_env().expect("Failed to create MovementRest");
rest_service.run_service().await.unwrap();
The error would occur because TcpListener::bind("http://0.0.0.0:30832") fails to parse the string into a valid SocketAddr.
Here's a simple test that demonstrates the failure:
Rust
#[tokio::test]
async fn test_server_binding_fails() {
let rest_service = MovementRest::try_from_env().expect("Failed to create MovementRest");
// Attempt to start the service
let result = rest_service.run_service().await;
// The binding should fail due to invalid URL format
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("invalid socket address"));
}
Fix
Fix is straightforward. Remove the HTTP scheme prefix from the default URL:
Or paarse the URL and extract only the host and port if a full URL is expected from the environment variable.
The original report as published on Immunefi, by Rhaydden. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 50 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The default URL string includes the 'http://' scheme, but TcpListener::bind expects a socket address in 'host:port' format, causing a parse error at runtime.
Impact
The REST API service would fail to start in any production environment, making all API endpoints inaccessible and rendering applications, wallets, or services that rely on it non-functional.
What the attacker needed
None
The fix
The fix is to remove the http:// scheme from the default URL so it is in host:port format, or parse the URL and extract only the host and port.
How it was found
Build and run the Movement REST service in a real environment.
The service attempts to bind using the default URL that includes the http:// scheme.
TcpListener::bind fails to parse the string as a socket address.
The service returns an error and does not start listening.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 50 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A service needs to listen on a network address to accept connections. The code gave it a full web address with 'http://' at the start, but the function that opens the listening port only understands a plain 'host:port' format. Because of this mismatch, the service crashes on startup and never becomes available.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.