Lorel / 0MQRxLua-MFR-POC

Try map filter reduce based on 0MQ and RxLua (et un peu de SGX)
0 stars 0 forks source link

LuaSGX limitation for passed data #3

Closed Lorel closed 7 years ago

Lorel commented 7 years ago

Data passed to the enclave seem to suffer a limitation

The following script passed to luasgx demonstrates it:

local l1 = "a123456789b123456789c123456789d123456789e123456789f12"
local l2 = "a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k123456789l123456789m123456789n123456789o123456789q123456789"

local f = "function(x) return x end"

print("Test 1")
print(l1)
print(sgxdecrypt( sgxprocess( sgxencrypt(f), sgxencrypt(l1))))

print("Test 2")
print(l2)
print(sgxdecrypt( sgxprocess( sgxencrypt(f), sgxencrypt(l2))))

Execution:

$ ./luasgx test-length.lua
token_path: /home/ahavet/enclave.lua2.token
Test 1
a123456789b123456789c123456789d123456789e123456789f12
a123456789b123456789c123456789d123456789e123456789f12
Test 2
a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k123456789l123456789m123456789n123456789o123456789q123456789
a123456789b123456789c123456789d123456789e123456789f123456789g123456789h12345678
Lorel commented 7 years ago

It has been fixed by rafael

$ ./luasgx test-length.lua
SCBR token_path: /home/ahavet/enclave.lua2.token
Test 1
a123456789b123456789c123456789d123456789e123456789f12
a123456789b123456789c123456789d123456789e123456789f12
Test 2
a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k123456789l123456789m123456789n123456789o123456789q123456789
a123456789b123456789c123456789d123456789e123

Apparently it was due to something wrong in the primitive sgxprocess with the cipher and some zeros (rafael can surely provide more explanation if needed) But there is indeed a limitation in the buffers used behind the primitive sgxprocess, which is 8kB for each argument and the return value

⚠️ otherwise, for now there is not any error or warning in case of buffer overflow ⚠️