Skip to content

Issue with locking down supressAccessChecks with Jackson Databind #992

@shorea

Description

@shorea

Customer reported issue with the AWS SDK for Java (aws/aws-sdk-java#528) asking for ability to restrict the permission supressAccessChecks in a security manager. Tried to fix the issue on our end by making all classes/constructors/methods involved in serialization public but was still getting exceptions from the databind library, specifically ClassUtils. Did a little investigation and found that the code handling SecurityExceptions seems to be incorrect.

/* 14-Jan-2009, tatu: It seems safe and potentially beneficial to
 *   always to make it accessible (latter because it will force
 *   skipping checks we have no use for...), so let's always call it.
 */
//if (!ao.isAccessible()) {
try {
    ao.setAccessible(true);
} catch (SecurityException se) {
    /* 17-Apr-2009, tatu: Related to [JACKSON-101]: this can fail on
     *    platforms like EJB and Google App Engine); so let's
     *    only fail if we really needed it...
     */
    if (!ao.isAccessible()) {
        Class<?> declClass = member.getDeclaringClass();
        throw new IllegalArgumentException("Can not access "+member+" (from class "+declClass.getName()+"; failed to set access: "+se.getMessage());
    }
}

The method isAccessible checks if access checks have been suppressed, i.e. not locked down by a security manager, rather then if the method/constructor/field is actually accessible per it's modifiers. If we are unable to suppress access checks can we not just proceed and have deserialization fail when the method is invoked? Unless I'm mistaken this makes Jackson unusable with a SecurityManager in place.

I'll put together a pull request for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions