Skip to content

Commit 299f804

Browse files
committed
Fix vulnerability in enc_untrusted_recvfrom
Change recvfrom memcpy to check for received_buffer size to avoid copying extra buffer. This issue was reported by Qinkun Bao, Zhaofeng Chen, Mingshen Sun, and Kang Li from Baidu Security. PiperOrigin-RevId: 322476299 Change-Id: I3606ff9ec51ec7cc4312c7555c645a2fc6e09b21
1 parent e582f36 commit 299f804

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

asylo/platform/host_call/trusted/host_calls.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ ssize_t enc_untrusted_recvfrom(int sockfd, void *buf, size_t len, int flags,
982982
}
983983

984984
auto buffer_received = output.next();
985-
memcpy(buf, buffer_received.data(), len);
985+
memcpy(buf, buffer_received.data(), std::min(len, buffer_received.size()));
986986

987987
// If |src_addr| is not NULL, and the underlying protocol provides the source
988988
// address, this source address is filled in. When |src_addr| is NULL, nothing

0 commit comments

Comments
 (0)