Skip to content

Commit e582f36

Browse files
committed
Check for output_len range in ecall_restore
This may cause vulnerablity if pointing to trusted memory. This issue was reported by Qinkun Bao, Zhaofeng Chen, Mingshen Sun, and Kang Li from Baidu Security. PiperOrigin-RevId: 322476223 Change-Id: I8a6406e9f07a20582d4387bd9a3469dfa9cbcb12
1 parent bc3fdb4 commit e582f36

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

asylo/platform/primitives/sgx/ecalls.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ int ecall_take_snapshot(char **output, uint64_t *output_len) {
6262
int ecall_restore(const char *input, uint64_t input_len, char **output,
6363
uint64_t *output_len) {
6464
if (!asylo::primitives::TrustedPrimitives::IsOutsideEnclave(input,
65-
input_len)) {
65+
input_len) ||
66+
!asylo::primitives::TrustedPrimitives::IsOutsideEnclave(
67+
output_len, sizeof(uint64_t))) {
6668
asylo::primitives::TrustedPrimitives::BestEffortAbort(
67-
"ecall_restore: input found to not be in untrusted memory.");
69+
"ecall_restore: input/output found to not be in untrusted memory.");
6870
}
6971
int result = 0;
7072
size_t tmp_output_len;

0 commit comments

Comments
 (0)