-
Notifications
You must be signed in to change notification settings - Fork 382
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
Server-side validate for rpc.enhancedClasses payloads #9880
Comments
Here are a few thoughts:
Given the above I would suggest using the Servlet API API wise I could imagine public class RemoteServiceServlet ... {
// To support public/private key cryptography the public key would
// need to be distributed manually. The API below does not allow
// sending a public key along every response.
interface SignatureHandler {
byte[] createEncryptedSignature(byte[] data);
boolean isValid(byte[] data, byte[] encryptedSignature);
}
private SignatureHandler signatureHandler;
@Override
public void init() {
super.init();
signatureHandler = createSignatureHandler();
}
protected SignatureHandler createSignatureHandler() {
// SHA256 + AES256 based, allows configuration of AES keys via system properties.
// Should cover most cases
return new DefaultSignatureHandler();
}
} The |
I think this can work - two payloads instead of one does offer the complication that it technically changes the wire format ("instead of one opaque string payload added to each object, there are now two"), but with the use of raw
I'm content to leave the other details to the implementor, if someone wants to volunteer or sponsor this work. I think however that you can sidestep the |
That's fine we should not forbid that. The above API allows public/private keys but does not easily allow every server in the cluster having its own key pair as you would need to find a way to figure out the public key to use during verification. Technically it is possible with the above API, although not obvious. Since the implementation is responsible to create and verify the signature, nobody stops it from adding additional information to the signature. So
Good point about changing data. I guess we should settle on a readonly ByteBuffer then. I don't like String because it requires knowledge about character encoding.
This was under the impression that we would revert the commit producing warnings/errors for the time being but instead always have a default implementation for signing in place if the developer does not provide its own implementation. That way enhanced classes can simply be used or experimented with without thinking about signing. |
Following #9709 and the PR #9879 to mitigate this by disabling the feature, this issue is to track efforts to make this feature safe to use again. There are several approaches that can be used to make this safe, and reasons that no one solution is a guaranteed fit for all applications, so I propose that we find a general extension point to add, and if populated by an application, permit the use of enhanced classes without warning or error.
Basic approaches:
onBeforeRequestDeserialized
can be overridden today to read from the request or session to validate in this way.ObjectInputStream
and surrounding code. In some cases it could be sufficient to offer a limited set of allowed classes that ObjectInputStream.resolveClass could read, and to check each one as it is read that it matches the expected field to write. SeeServerSerializationStreamReader.checkResolve
for the current implementation here.Option 1 seems to be the superior choice in terms of granting flexibility and not requiring trusting malicious clients, but it also likely requires the most flexible configuration. We could go so far as to delegate this as a simple interface such as
and offer a simple (single server), in-memory only (won't survive restarts) implementation to start from, and configuration to provide a custom implementation.
The text was updated successfully, but these errors were encountered: