You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Configure the following parameters in poc.py: poc.py
target_ip and target_port: The IP and port of the chip-all-clusters-app instance.
interface: The name of your local network interface.
Execute poc.py with the command: sudo python3 poc.py.
Observe that the chip-all-clusters-app crashes, producing the following crash log: crash_log.txt
Summary
A vulnerability in the TCP-based Matter packet handling allows an unauthenticated attacker to trigger a crash by sending a single malformed packet. The issue stems from improper management of packet during message parsing, leading to a null pointer dereference. This affects all Matter implementations that rely on the TCP packet handling logic and can result in a complete Denial of Service (DoS).
Description and Analysis
Parsing the Packet Length
TCP-based Matter packets encode the payload length in the first 4 bytes. In the TCPBase::ProcessReceivedBuffer function, this length is read using the Read() method and stored in the messageSize variable.
CHIP_ERROR TCPBase::ProcessReceivedBuffer(Inet::TCPEndPoint * endPoint, const PeerAddress & peerAddress,
System::PacketBufferHandle && buffer)
{
ActiveTCPConnectionState * state = FindActiveConnection(endPoint);
VerifyOrReturnError(state != nullptr, CHIP_ERROR_INTERNAL);
state->mReceived.AddToEnd(std::move(buffer));
while (!state->mReceived.IsNull())
{
uint8_t messageSizeBuf[kPacketSizeBytes];
CHIP_ERROR err = state->mReceived->Read(messageSizeBuf);
if (err == CHIP_ERROR_BUFFER_TOO_SMALL)
{
// Not enough data to read the message size. Wait for more data.return CHIP_NO_ERROR;
}
if (err != CHIP_NO_ERROR)
{
return err;
}
uint32_t messageSize = LittleEndian::Get32(messageSizeBuf);
Consuming Length Bytes
Before the ProcessSingleMessage function is invoked, the 4-byte length field is consumed using the Consume() method.
To prevent this issue, a null pointer check should be added for state->mReceived before invoking ProcessSingleMessage. This ensures the function is not called when state->mReceived is nullptr.
Reproduction steps
Run
chip-all-clusters-app
.Configure the following parameters in
poc.py
:poc.py
target_ip
andtarget_port
: The IP and port of thechip-all-clusters-app
instance.interface
: The name of your local network interface.Execute
poc.py
with the command:sudo python3 poc.py
.Observe that the
chip-all-clusters-app
crashes, producing the following crash log:crash_log.txt
Summary
A vulnerability in the TCP-based Matter packet handling allows an unauthenticated attacker to trigger a crash by sending a single malformed packet. The issue stems from improper management of packet during message parsing, leading to a null pointer dereference. This affects all Matter implementations that rely on the TCP packet handling logic and can result in a complete Denial of Service (DoS).
Description and Analysis
Parsing the Packet Length
TCP-based Matter packets encode the payload length in the first 4 bytes. In the
TCPBase::ProcessReceivedBuffer
function, this length is read using theRead()
method and stored in themessageSize
variable.Consuming Length Bytes
Before the
ProcessSingleMessage
function is invoked, the 4-byte length field is consumed using theConsume()
method.Invoke FreeHead Function
If the length to consume (
aConsumeLength
) exceeds or equals the remaining buffer length (kLength
), theFreeHead()
function is invoked.Return nullptr
When
ChainedBuffer
is not present,lNextPacket
becomesnullptr
. This value is returned, causingstate->mReceived
'smBuffer
to becomenullptr
.Crash via Null Pointer Dereference
When
ProcessSingleMessage
is executed,state->mReceived
isnullptr
, leading to a null pointer dereference and a crash.Debug Output:
Proposed Solution
To prevent this issue, a null pointer check should be added for
state->mReceived
before invokingProcessSingleMessage
. This ensures the function is not called whenstate->mReceived
isnullptr
.Bug prevalence
always
GitHub hash of the SDK that was being used
ffbc362
Platform
core
Platform Version(s)
all versions with TCP support
Anything else?
No response
The text was updated successfully, but these errors were encountered: