Stack buffer overflow in Tracing (CVE-2025-0438)
A stack buffer overflow occurs in the tracing service when an environment variable controlling the producer socket name is copied into a fixed-size buffer without bounds checking. An attacker who can control that environment variable could overwrite the stack and potentially execute arbitrary code.
- Fix shipped in 31 days
Steps to reproduce the problem
- apply the patch (equal to setting the environment variable)
- run ./services_unittests --gtest_filter=SystemTracingServiceTest.OpenProducerSocket_Nonexistent
Problem Description
I'm not sure if it's a valid assumption (attacker controls the environment variable), but to be safe I reported it.
RCA
In ProducerSocketConnector::ConnectSocket, the producer_sock_name [1] can be read from a
environment variable PERFETTO_PRODUCER_SOCK_NAME[3], so if adversary can control the environment
variable, the size of the name can be arbitary long.
Then at [2], the producer_sock_name is copied to the struct sockaddr_un's sun_path,
which is fixed for 108 bytes. Therefore, the attacker can craft the PERFETTO_PRODUCER_SOCK_NAME
to overwrite the stack, as much as they want.
// services/tracing/public/cpp/system_tracing_service.cc
base::expected<bool, int> ConnectSocket() {
std::string producer_sock_name = perfetto::GetProducerSocket(); // [1]
socket_fd_.reset(socket(AF_UNIX, SOCK_STREAM, 0));
if (socket_fd_.get() == -1) {
return base::unexpected(errno);
}
struct sockaddr_un saddr;
memset(&saddr, 0, sizeof(saddr));
memcpy(saddr.sun_path, producer_sock_name.data(), // [2]
producer_sock_name.size());
}
// third_party/perfetto/src/tracing/ipc/default_socket.cc
const char* GetProducerSocket() {
const char* name = getenv("PERFETTO_PRODUCER_SOCK_NAME"); // [3]
if (name == nullptr) {
// ...
}
base::ignore_result(UseRunPerfettoBaseDir); // Silence unused func warnings.
return name;
}
struct sockaddr_un {
sa_family_t sun_family; /* AF_UNIX */
char sun_path[108]; /* Pathname */ //[4]
};
Summary
Security: Potential Stack-Buffer-Overflow in ProducerSocketConnector::ConnectSocket
Custom Questions
Type of crash:
browser
Reporter credit:
Han Zheng (HexHive)
Additional Data
Category: Security
Chrome Channel: Not sure
Regression: N/A
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
If an attacker can control the environment variable, they could overwrite the stack and potentially execute arbitrary code, though the report notes uncertainty about whether this assumption is valid.
What the attacker needed
Attacker controls PERFETTO_PRODUCER_SOCK_NAME
How it was found
- Apply the patch (equivalent to setting the environment variable).
- Run the unit test SystemTracingServiceTest.OpenProducerSocket_Nonexistent.
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.
A program copies a name from an environment variable into a small, fixed-size space on the stack without checking if the name is too long. If an attacker can set that environment variable to a very long value, the extra data spills over and overwrites other important data on the stack, which can crash the program or let the attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.