Re: Explicit Serialization API and Security

2015-02-06 Thread Peter Firmstone
Some performance figures, atomic de-serialization using loopback local network sockets, codebase downloads, dynamic class loading, with security manager and policies in force and Jini extensible remote method invocation, there's communication going on between 4 different jvm instances, the one

Re: Explicit Serialization API and Security

2015-02-06 Thread Peter Firmstone
A simpler example of production code modified to support @AtomicSerial that satisfies invariants follows. Note how we can't type check Generics with the static validator method, but the compiler does it for us with the constructor :) I'm wondering if there's scope for secure alternatives of

Re: Explicit Serialization API and Security

2015-02-03 Thread Chris Hegarty
Hi Peter, On 2 Feb 2015, at 11:16, Peter Firmstone peter.firmst...@zeus.net.au wrote: As mentioned I've been experimenting with an invariant validating ObjectInputStream, that's backward and forward compatible with Java's Object Serialization stream protocol. No changes have been made to

Re: Explicit Serialization API and Security

2015-02-02 Thread Peter Firmstone
As mentioned I've been experimenting with an invariant validating ObjectInputStream, that's backward and forward compatible with Java's Object Serialization stream protocol. No changes have been made to ObjectOutputStream. ObjectInputStream has been overridden and reading from the stream has

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
Logging output from failed validation: NonActGrp-out: Jan 29, 2015 7:36:16 PM net.jini.jeri.BasicInvocationHandler invoke NonActGrp-out: Jan 29, 2015 7:36:16 PM net.jini.jeri.BasicInvocationHandler invoke NonActGrp-out: FAILED: outbound call net.jini.core.event.RemoteEventListener.notify

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
Although not directly relevant to this discussion, here are some functional examples of deserialization constructors, I now have a fully functional validating ObjectInputStream. Unfortunately in our project we have intra object dependencies as demonstrated by this example; a static validator,

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
Just a quick note, to avoid stream corruption, object that aren't instantiated are replaced by an enum marker, Reference.DISCARDED, and null is returned in their place, fields are read and any trailling writeObject data is discarded. Object that are not allowed to be deserialized are still

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
For the sharper eyed, you'll have noticed the readObjectNoData() method I forgot to check: private static boolean check(GetArg arg) throws IOException{ // If this class is not in the heirarchy of classes the stream // may have been tampered with, see the Serialization Specification

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
Two examples: 1. of a child class with super class invariants and 2. Checking List and Map contents for type correctness. /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
Another example of intra dependencies, turns out we have a lot of these intra class dependencies in our project. Cheers, Peter. /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for

Re: Explicit Serialization API and Security

2015-01-29 Thread Peter Firmstone
I decided to sample cpu load (see attached), with debugging enabled for the validating ObjectInputStream and JERI, so heaps of output to the console. There are no performance optimisations with stream validation, I've just focused on correctness and security. Thank you HotSpot developers,

Re: Explicit Serialization API and Security

2015-01-23 Thread Chris Hegarty
I have attempted to capture some of the ideas that we have discussed so far. https://bugs.openjdk.java.net/browse/JDK-8071471 -Chris. On 21/01/15 21:43, David M. Lloyd wrote: At some point, the responsibility *must* fall on the author of the serializable class in question to avoid constructs

Re: Explicit Serialization API and Security

2015-01-22 Thread Peter Firmstone
And that is the point of this discussion, to determine how to do just that. But considering it's such a difficult problem, we haven't figured out how to yet. Peter. - Original message - Message: 2 Date: Wed, 21 Jan 2015 15:43:13 -0600 From: David M. Lloyd david.ll...@redhat.com

Re: Explicit Serialization API and Security

2015-01-21 Thread Chris Hegarty
On 20/01/15 20:22, Peter Levart wrote: Hi Chris and Peter, It just occurred to me that the following scheme would provide failure atomicity for the whole Object regardless of whether readObject methods are used or not for various classes in hierarchy: - allocate uninitialized instance - call

Re: Explicit Serialization API and Security

2015-01-21 Thread Peter Firmstone
Don't forget that null may also be an invalid state. What I have learnt so far: 1. An attacker can craft a stream to obtain a reference to any object created during deserialization, using finalizers or circular links (there may be yet other undiscovered methods). 2. An attacker

Re: Explicit Serialization API and Security

2015-01-21 Thread David M. Lloyd
At some point, the responsibility *must* fall on the author of the serializable class in question to avoid constructs which are exploitable - like finalizers, and classes that can have side-effects before validation can be completed. On 01/21/2015 02:26 PM, Peter Firmstone wrote: Don't

Re: Explicit Serialization API and Security

2015-01-20 Thread Peter Levart
Hi Chris and Peter, It just occurred to me that the following scheme would provide failure atomicity for the whole Object regardless of whether readObject methods are used or not for various classes in hierarchy: - allocate uninitialized instance - call default accessible constructor of the

Re: Explicit Serialization API and Security

2015-01-17 Thread Peter Firmstone
- Original message - On 15/01/15 20:33, Peter Firmstone wrote: Thanks Chris, WRT circular references, is it possible to detect and delay setting these until after all verifiers run? It is possible to detect the circular reference. Currently you can retrieve a circular

Re: Explicit Serialization API and Security

2015-01-16 Thread Chris Hegarty
On 15/01/15 20:33, Peter Firmstone wrote: Thanks Chris, WRT circular references, is it possible to detect and delay setting these until after all verifiers run? It is possible to detect the circular reference. Currently you can retrieve a circular reference ( in readObject ) from

Re: Explicit Serialization API and Security

2015-01-15 Thread Chris Hegarty
On 15 Jan 2015, at 12:25, Peter Firmstone peter.firmst...@zeus.net.au wrote: Chris, Can you explain some of the detail in your failure atomicity work? Certainly. The current implementation of defaultReadObject sets non-primitive field values one at a time, without first checking that all

Re: Explicit Serialization API and Security

2015-01-15 Thread Peter Firmstone
Thanks Chris, WRT circular references, is it possible to detect and delay setting these until after all verifiers run? An option might be to provide a protected method in ObjectInputStream to opt out or switch off support for circular references. Apart from Serialization, another common use

Re: Explicit Serialization API and Security

2015-01-15 Thread Peter Firmstone
Chris, Can you explain some of the detail in your failure atomicity work? Thanks, Peter.

Re: Explicit Serialization API and Security

2015-01-15 Thread Peter Firmstone
On 13/01/2015 1:56 AM, Chris Hegarty wrote: On 10/01/15 07:00, Peter Firmstone wrote: As shown in my earlier example, intra class invariants can be enforced using Serialization constructors, from which static methods are called to check invariants prior to super class constructors being

Re: Explicit Serialization API and Security

2015-01-15 Thread Stephen Colebourne
On 15 January 2015 at 13:01, Peter Firmstone peter.firmst...@zeus.net.au wrote: A third option that hasn't yet been considered would be to investigate an api that various already existing frameworks can implement providers for, so they no longer need to find creative ways to construct instances

Re: Explicit Serialization API and Security

2015-01-14 Thread Peter Firmstone
It's only top down if there are intra class invariants, in this case invariants are checked more than once. This done simply because we can't move up the constructor call chain untill all child class invariants have been satisfied. For simpler class relationships, invariant check order is

Re: Explicit Serialization API and Security

2015-01-14 Thread Peter Levart
On 01/14/2015 12:37 PM, Chris Hegarty wrote: What do you think? I agree completely. An API at the level that you are proposing will provide the necessary functionality and flexibility that is required to do validation in readObject. As you clearly stated, and is already the case,

Re: Explicit Serialization API and Security

2015-01-14 Thread Peter Firmstone
The following is a summary of our exploration so far: We have narrowed down to two options: A. constructors with static invariant check methods. B. Continue to use readObject(), we have a proposed solution to the final field problem and could modify the jvm to register for finalization

Re: Explicit Serialization API and Security

2015-01-14 Thread Chris Hegarty
On 13/01/15 10:00, Peter Levart wrote: Hi Chris, I stepped back and asked myself what problem(s) we are searching solution(s) for and tried to see how existing API solves or doesn't solve them. I think that existing readObject() + GetFields API already solves most of the problems discussed so

Re: Explicit Serialization API and Security

2015-01-14 Thread Chris Hegarty
On 13/01/15 00:51, Peter Firmstone wrote: - Original message - On 10/01/15 07:00, Peter Firmstone wrote: Again, thank you all for engaging in discussion of this very difficult topic. While we can't presently check intra object dependencies during deserialization with

Re: Explicit Serialization API and Security

2015-01-14 Thread Peter Firmstone
Hi Chris, Sorry, no. Currently when an ObjectStreamClass is read in from the stream, the framework searches for the first zero arg constructor of a non serializable class and creates and instance of the class read and resolved from the stream, however it does so using a super class

Re: Explicit Serialization API and Security

2015-01-14 Thread Chris Hegarty
On 14/01/15 12:58, Peter Firmstone wrote: Hi Chris, Sorry, no. Currently when an ObjectStreamClass is read in from the stream, the framework searches for the first zero arg constructor of a non serializable class and creates and instance of the class read and resolved from the stream, however

Re: Explicit Serialization API and Security

2015-01-13 Thread Peter Levart
Hi Chris, I stepped back and asked myself what problem(s) we are searching solution(s) for and tried to see how existing API solves or doesn't solve them. I think that existing readObject() + GetFields API already solves most of the problems discussed so far as it: - provides encapsulation

Re: Explicit Serialization API and Security

2015-01-13 Thread Peter Firmstone
Could we use a static validator method and generate bytecode for constructors dynamically? The developer can optionally implement the constructors. static GetField invariantCheck(GetField f); Create a caller sensitive GetField implementation and add a two new methods to GetField: abstract

Re: Explicit Serialization API and Security

2015-01-12 Thread Chris Hegarty
On 08/01/15 20:10, Brian Goetz wrote: 1) Validate invariants A clear and easy to understand mechanism that can validate the deserialized fields. Does not prevent the use of final fields, as the serialization framework will be responsible for setting them. Something along the

Re: Explicit Serialization API and Security

2015-01-12 Thread Chris Hegarty
On 08/01/15 22:03, David M. Lloyd wrote: private static void validate(GetField fields) { if (fields.getInt(lo) fields.getInt(hi)) { ... } } ... In fact you cannot validate invariants across multiple objects at all using this method *or* readObject() (existing

Re: Explicit Serialization API and Security

2015-01-12 Thread Patrick Reinhart
Am 12.01.2015 um 17:15 schrieb Stephen Colebourne scolebou...@joda.org: On 12 January 2015 at 11:37, Chris Hegarty chris.hega...@oracle.com wrote: For clarity, I would like to describe how things currently work. 1) Allocate a new instance of the deserialized type. 2) Call the first

Re: Explicit Serialization API and Security

2015-01-12 Thread Peter Firmstone
- Original message - On 10/01/15 07:00, Peter Firmstone wrote: Again, thank you all for engaging in discussion of this very difficult topic. While we can't presently check intra object dependencies during deserialization with readObject(), the examples I provide can do

Re: Explicit Serialization API and Security

2015-01-12 Thread Chris Hegarty
On 10/01/15 07:00, Peter Firmstone wrote: Again, thank you all for engaging in discussion of this very difficult topic. While we can't presently check intra object dependencies during deserialization with readObject(), the examples I provide can do this. I have replied to Davids mail with a

Re: Explicit Serialization API and Security

2015-01-12 Thread David M. Lloyd
On 01/12/2015 05:51 AM, Chris Hegarty wrote: On 08/01/15 22:03, David M. Lloyd wrote: private static void validate(GetField fields) { if (fields.getInt(lo) fields.getInt(hi)) { ... } } ... In fact you cannot validate invariants across multiple objects at all

Re: Explicit Serialization API and Security

2015-01-12 Thread Stephen Colebourne
On 12 January 2015 at 11:37, Chris Hegarty chris.hega...@oracle.com wrote: For clarity, I would like to describe how things currently work. 1) Allocate a new instance of the deserialized type. 2) Call the first non-Serializable types no-arg constructor ( may be j.l.Object ). 3) For

Re: Explicit Serialization API and Security

2015-01-09 Thread Peter Firmstone
Again, thank you all for engaging in discussion of this very difficult topic. While we can't presently check intra object dependencies during deserialization with readObject(), the examples I provide can do this. ObjectInputValidation is sufficient for enforcing business rules, however it

Re: Explicit Serialization API and Security

2015-01-08 Thread David M. Lloyd
On 01/08/2015 02:10 PM, Brian Goetz wrote: 1) Validate invariants A clear and easy to understand mechanism that can validate the deserialized fields. Does not prevent the use of final fields, as the serialization framework will be responsible for setting them. Something along the

Re: Explicit Serialization API and Security

2015-01-08 Thread Peter Firmstone
Thank you all for participating in this discussion. Initially a constructor signature for deserialization was proposed to enforce invariants and encapsulation, however there appears to be interest in using alternative methods, although they appear to be improvements over the status quo, I'm

Re: Explicit Serialization API and Security

2015-01-08 Thread David M. Lloyd
On 01/08/2015 02:32 AM, Peter Firmstone wrote: Thank you all for participating in this discussion. Initially a constructor signature for deserialization was proposed to enforce invariants and encapsulation, however there appears to be interest in using alternative methods, although they appear

Re: Explicit Serialization API and Security

2015-01-08 Thread Chris Hegarty
Peter, David I would like to see how far we can push the existing Serialization mechanism, before embarking on a road that may lead us to substantially different one. Whether that be constructor based, to otherwise ( we know we will need a replacement for Unsafe.allocateInstance, for

Re: Explicit Serialization API and Security

2015-01-08 Thread Brian Goetz
1) Validate invariants A clear and easy to understand mechanism that can validate the deserialized fields. Does not prevent the use of final fields, as the serialization framework will be responsible for setting them. Something along the lines of what David suggested:

Re: Explicit Serialization API and Security

2015-01-07 Thread Chris Hegarty
On 06/01/15 17:49, Peter Levart wrote: On 01/06/2015 06:21 PM, Chris Hegarty wrote: On 6 Jan 2015, at 15:06, Peter Levart peter.lev...@gmail.com wrote: On 01/06/2015 04:03 PM, Peter Levart wrote: private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

Re: Explicit Serialization API and Security

2015-01-07 Thread Peter Levart
On 01/07/2015 03:54 PM, Chris Hegarty wrote: On 06/01/15 17:49, Peter Levart wrote: On 01/06/2015 06:21 PM, Chris Hegarty wrote: On 6 Jan 2015, at 15:06, Peter Levart peter.lev...@gmail.com wrote: On 01/06/2015 04:03 PM, Peter Levart wrote: private void readObject(ObjectInputStream in)

Re: Explicit Serialization API and Security

2015-01-07 Thread David M. Lloyd
On 01/07/2015 10:02 AM, Peter Levart wrote: On 01/07/2015 03:54 PM, Chris Hegarty wrote: On 06/01/15 17:49, Peter Levart wrote: On 01/06/2015 06:21 PM, Chris Hegarty wrote: On 6 Jan 2015, at 15:06, Peter Levart peter.lev...@gmail.com wrote: On 01/06/2015 04:03 PM, Peter Levart wrote:

Re: Explicit Serialization API and Security

2015-01-06 Thread Chris Hegarty
On 6 Jan 2015, at 08:31, Stephen Colebourne scolebou...@joda.org wrote: On 6 January 2015 at 07:27, Peter Levart peter.lev...@gmail.com wrote: readObject() can be used on both ends of the spectrum or anywhere in-between. It can be used for explicit deserialization or just for validation of

Re: Explicit Serialization API and Security

2015-01-06 Thread Stephen Colebourne
On 6 January 2015 at 07:27, Peter Levart peter.lev...@gmail.com wrote: readObject() can be used on both ends of the spectrum or anywhere in-between. It can be used for explicit deserialization or just for validation of default deserialized state. Would separate validation method give us

Re: Explicit Serialization API and Security

2015-01-06 Thread Chris Hegarty
On 6 Jan 2015, at 07:27, Peter Levart peter.lev...@gmail.com wrote: Hi Brian, On 01/05/2015 09:51 PM, Brian Goetz wrote: Thanks Peter(s): I think it's just about time to re-sync on the goals, since there are an infinitude of issues with serialization, only some of which we can address.

Re: Explicit Serialization API and Security

2015-01-06 Thread Stephen Colebourne
On 6 January 2015 at 10:25, Chris Hegarty chris.hega...@oracle.com wrote: On 6 Jan 2015, at 08:31, Stephen Colebourne scolebou...@joda.org wrote: I've thought on a number of occasions that what I wanted from serializable was a merger of readObject and readResolve private Object

Re: Explicit Serialization API and Security

2015-01-06 Thread Peter Firmstone
- Original message - On 5/01/2015 6:51 PM, Peter Firmstone wrote: Thanks Dave, That's another way of checking invariants, you could expose A's check method but you'd also need a couple of additional static methods to obtain integers upper and lower from ReadSerial,

Re: Explicit Serialization API and Security

2015-01-06 Thread Chris Hegarty
On 5 Jan 2015, at 20:51, Brian Goetz brian.go...@oracle.com wrote: Thanks Peter(s): I think it's just about time to re-sync on the goals, since there are an infinitude of issues with serialization, only some of which we can address. To that end, let me toss out some of the results of our

Re: Explicit Serialization API and Security

2015-01-06 Thread Stephen Colebourne
On 6 January 2015 at 11:46, Chris Hegarty chris.hega...@oracle.com wrote: With shallow/no hierarchies, and others, the serialization proxy pattern works quite well. The overhead of course being the creation of the proxy itself, but this is typically a minimal container with just the state

Re: Explicit Serialization API and Security

2015-01-06 Thread Chris Hegarty
On 6 Jan 2015, at 11:13, Stephen Colebourne scolebou...@joda.org wrote: On 6 January 2015 at 10:25, Chris Hegarty chris.hega...@oracle.com wrote: On 6 Jan 2015, at 08:31, Stephen Colebourne scolebou...@joda.org wrote: I've thought on a number of occasions that what I wanted from serializable

Re: Explicit Serialization API and Security

2015-01-06 Thread Peter Levart
Hi Chris, On 01/06/2015 12:10 PM, Chris Hegarty wrote: On 6 Jan 2015, at 07:27, Peter Levart peter.lev...@gmail.com wrote: Hi Brian, On 01/05/2015 09:51 PM, Brian Goetz wrote: Thanks Peter(s): I think it's just about time to re-sync on the goals, since there are an infinitude of issues with

Re: Explicit Serialization API and Security

2015-01-06 Thread Peter Levart
On 01/06/2015 04:03 PM, Peter Levart wrote: private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = in.readFields(); // this already validates the types Well, not true currently. But type validation could be added

Re: Explicit Serialization API and Security

2015-01-06 Thread Peter Levart
On 01/06/2015 06:21 PM, Chris Hegarty wrote: On 6 Jan 2015, at 15:06, Peter Levart peter.lev...@gmail.com wrote: On 01/06/2015 04:03 PM, Peter Levart wrote: private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields =

Re: Explicit Serialization API and Security

2015-01-06 Thread Chris Hegarty
On 6 Jan 2015, at 15:06, Peter Levart peter.lev...@gmail.com wrote: On 01/06/2015 04:03 PM, Peter Levart wrote: private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = in.readFields(); // this already validates

Re: Explicit Serialization API and Security

2015-01-05 Thread Peter Levart
Hi Brian, On 01/05/2015 09:51 PM, Brian Goetz wrote: Thanks Peter(s): I think it's just about time to re-sync on the goals, since there are an infinitude of issues with serialization, only some of which we can address. To that end, let me toss out some of the results of our recent

Re: Explicit Serialization API and Security

2015-01-05 Thread Peter Firmstone
My mistake, thank you. Peter. On 5/01/2015 9:57 PM, David Holmes wrote: Hi Peter, Did you send this to the list? I haven't seen it turn up yet. David On 5/01/2015 6:51 PM, Peter Firmstone wrote: Thanks Dave, That's another way of checking invariants, you could expose A's check method but

Re: Explicit Serialization API and Security

2015-01-05 Thread Peter Levart
Hi Peter and others, A assume your approach described here (to use constructors for deserialization) is motivated mainly by the fact that only constructors are allowed to set the final fields. Otherwise the explicit features of your ReadSerial API are more or less accessible even now by using

Re: Explicit Serialization API and Security

2015-01-05 Thread David M. Lloyd
On 01/03/2015 09:36 AM, Peter Levart wrote: On 01/03/2015 01:38 PM, Peter Firmstone wrote: Hi, I would like to know what are the potential issues with simple constructor chaining where each constructor checks the invariant of its class state (with the already initialized state of

Re: Explicit Serialization API and Security

2015-01-05 Thread David M. Lloyd
On 01/03/2015 02:29 PM, Peter Firmstone wrote: - Original message - Wouldn't it be better to register for finalization just those instances that complete their construction or deserialization normally? I'm just trying to understand why it is the way it is. Perhaps that might be an

Re: Explicit Serialization API and Security

2015-01-05 Thread Peter Levart
On 01/05/2015 03:17 PM, David M. Lloyd wrote: Would something like this prevent Finalizer attacks? - leave finalization registration the way it is (at object allocation time). This was written incorrectly: after Object default constructor completes - provide internal API with which a

Re: Explicit Serialization API and Security

2015-01-05 Thread David Holmes
On 5/01/2015 6:51 PM, Peter Firmstone wrote: Thanks Dave, That's another way of checking invariants, you could expose A's check method but you'd also need a couple of additional static methods to obtain integers upper and lower from ReadSerial, so that B can ensure its invariant. Not sure I

Re: Explicit Serialization API and Security

2015-01-05 Thread Brian Goetz
Thanks Peter(s): I think it's just about time to re-sync on the goals, since there are an infinitude of issues with serialization, only some of which we can address. To that end, let me toss out some of the results of our recent explorations with improving serialization, where we started out

Re: Explicit Serialization API and Security

2015-01-04 Thread Peter Firmstone
- Original message - On 01/04/2015 02:48 AM, Peter Firmstone wrote: class B extends A { public final int cur; private static ReadSerial check(ReadSerial rs) { A a = new A(rs); What to do if A is abstract? :) Create an anonymous instance, or create a static private

Re: Explicit Serialization API and Security

2015-01-04 Thread Peter Levart
On 01/04/2015 02:48 AM, Peter Firmstone wrote: class B extends A { public final int cur; private static ReadSerial check(ReadSerial rs) { A a = new A(rs); What to do if A is abstract? Regards, Peter int cur = rs.getInt(cur); if ( a.lower cur || cur a.upper )

Re: Explicit Serialization API and Security

2015-01-04 Thread David Holmes
On 3/01/2015 9:24 PM, Peter Firmstone wrote: Thanks Brian, Those are good questions, some thoughts and examples inline: - Original message - Overall the direction seems promising. Poking at it a bit... - ReadSerial methods are caller-sensitive and only show a class a view of

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Firmstone
Hi, I would like to know what are the potential issues with simple constructor chaining where each constructor checks the invariant of its class state (with the already initialized state of superclass(es)). Finalizer attack; a subclass can override the finalize method and receive a

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Levart
On 01/02/2015 11:53 PM, Brian Goetz wrote: Overall the direction seems promising. Poking at it a bit... - ReadSerial methods are caller-sensitive and only show a class a view of its own fields. - Invariant checking is separate from deserialization, and does not seem entirely built-in --

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Firmstone
- Original message - As Brian points out, this scheme can only validate intra-class invariants. It can't validate class-against-subclass state. Did he say that? It's true that a superclass can't validate subclass state, it can't be expected to know much about it, but it can validate

Re: Explicit Serialization API and Security

2015-01-03 Thread Chris Hegarty
Just a quick comment about the finalization aspect ( as I have been thinking about this too ). On 3 Jan 2015, at 15:36, Peter Levart peter.lev...@gmail.com wrote: On 01/03/2015 01:38 PM, Peter Firmstone wrote: Hi, I would like to know what are the potential issues with simple

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Firmstone
Thanks Brian, Those are good questions, some thoughts and examples inline: - Original message - Overall the direction seems promising.  Poking at it a bit...     - ReadSerial methods are caller-sensitive and only show a class a view of its own fields.     - Invariant checking is

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Levart
On 01/03/2015 01:38 PM, Peter Firmstone wrote: Hi, I would like to know what are the potential issues with simple constructor chaining where each constructor checks the invariant of its class state (with the already initialized state of superclass(es)). Finalizer attack; a subclass can

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Firmstone
P.S. Thanks for engaging this difficult subject. It's worth remembering the finalizer attack isn't the only issue, a subclass will have a reference after construction completes, it has a thread of execution and if the superclass hasn't checked invarients, because circular links haven't been

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Levart
On 01/03/2015 09:29 PM, Peter Firmstone wrote: - Original message - As Brian points out, this scheme can only validate intra-class invariants. It can't validate class-against-subclass state. Sorry, I meant it can't validate class -against-superclass state. Did he say that? Not

Re: Explicit Serialization API and Security

2015-01-03 Thread Peter Firmstone
On 4/01/2015 9:55 AM, Peter Levart wrote: - Original message - As Brian points out, this scheme can only validate intra-class invariants. It can't validate class-against-subclass state. Sorry, I meant it can't validate class -against-superclass state. Did he say that? Not

Re: Explicit Serialization API and Security

2015-01-02 Thread Brian Goetz
Overall the direction seems promising. Poking at it a bit... - ReadSerial methods are caller-sensitive and only show a class a view of its own fields. - Invariant checking is separate from deserialization, and does not seem entirely built-in -- subclass constructors seem responsible for

Re: Explicit Serialization API and Security

2015-01-01 Thread Peter Firmstone
Subclass example: class SubFoo extends BaseFoo { public static ReadSerial check(ReadSerial rs){ if (rs.getInt(y) 128) throw Exception(too big); return rs; } private final int y; public SubFoo( int x , int y) { super(x); this.y = y; }

Re: Explicit Serialization API and Security

2014-12-31 Thread Peter Firmstone
Not quite, the constructor signature is the same for super and child classes. ReadSerial is a container for each serialized Object in an ObjectInputStream that provides and controlls access to serial fields, identified by name, type and calling class, such that each class has it's own

Re: Explicit Serialization API and Security

2014-12-30 Thread Stephen Colebourne
Just to note that there is some overlap between improving serialization and the meta-model for Java (Beans v2.0) work I'm looking at [1][2]. The key tool that a meta-model provides is to enable class authors to select which pieces of their state form the published properties. In most cases, the

Re: Explicit Serialization API and Security

2014-12-29 Thread Brian Goetz
So, if I understand this correctly, the way this would get used is: class BaseFoo implements Serializable { private final int x; public BaseFoo(ReadSerial rs) { this(rs.getInt(x)); } public BaseFoo(int x) { this.x = x; } } Right? What happens with