-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stamp proxies to prevent reentrancy / interleaving #3905
Comments
Another motivation: robust |
How? |
IIUC, to avoid executing any user code during Note that Is this what you have in mind? |
(In my head, I just started hearing the Wizard of Oz movie scarecrow singing "If I only had a write barrier". Ironically, the meter doesn't quite work.) |
Correct, The interesting bit is the layering between ses-shim / lockdown, |
What is the Problem Being Solved?
Untrusted code executed in a liveslots Compartment may create a proxy for a hardened object, which would behave like a hardened object (thanks to the language invariants), but be able to observe when properties are being accessed. That would allow attacker code to interleave at that point which could perform reentrancy type attacks.
This is a problem only for intra-vat code, with potential attack surface in at least 2 cases:
passStyleOf
ofcopyRecord
orcopyArray
objects may share a reference within a vat, and traversing such objects would not be expected to cause interleaving.Description of the Design
The idea is to be able to identify proxies where plain objects are expected while allowing proxies to be used normally in user code. This can be accomplished by overriding the
Proxy
constructor in the liveslots compartment with a version that stamps the instances it creates (e.g. adding them to aWeakSet
), and creating a power that checks if a given object is in that set.The original
Proxy
constructor needs to be completely denied, which can be accomplished by theinescapableGlobalProperties
of liveSlots. In the future such propagated globals may become a built-in feature of theCompartment
API.In the ZCF to contract case, it all executes within the liveSlot compartment, which would thus need the proxy stamp checking power. Since the power to detect any proxy may be considered sensitive and denied to non privileged code, we may need to restrict the power to "privileged" code running inside the compartment. For example only the
@agoric/marshal
module, and in particular itspassStyleOf
helper may need this power.Two high level options may be possible to restrict a power inside a Compartment:
globalLexical
and deny it from unprivileged code. The problem is the denial part since it's not possible to differentiate privileged from unprivileged code inside a bundle. One workaround might be a static checker which allows exactly a single lexical use of the power, then verify that the bundle includes the module which is supposed to exercise the power.Security Considerations
Escaping the stamping
Proxy
constructor would allow a complete bypass of the mechanism this is proposing, so the global must be inescapable.The power to read a proxy stamp may be sensitive and denied to unprivileged code.
Test Plan
TBD, but verify that user constructed proxies can be identified in the different locations where we believe they could cause the most harm.
The text was updated successfully, but these errors were encountered: