Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Not only Guinness - Linux is good for you, too. -- Banzai on IRC


devel / comp.lang.java.programmer / LDAP, .setReturningObjFlag(true) and alternatives...

SubjectAuthor
* LDAP, .setReturningObjFlag(true) and alternatives...Andreas Leitgeb
`* Re: LDAP, .setReturningObjFlag(true) and alternatives...Arne Vajhøj
 `* Re: LDAP, .setReturningObjFlag(true) and alternatives...Andreas Leitgeb
  `- Re: LDAP, .setReturningObjFlag(true) and alternatives...Arne Vajhøj

1
LDAP, .setReturningObjFlag(true) and alternatives...

<slrnuiimne.9968.avl@logic.at>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=303&group=comp.lang.java.programmer#303

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: avl@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.java.programmer
Subject: LDAP, .setReturningObjFlag(true) and alternatives...
Date: Fri, 13 Oct 2023 14:57:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <slrnuiimne.9968.avl@logic.at>
Reply-To: avl@logic.at
Injection-Date: Fri, 13 Oct 2023 14:57:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9edd2c69b91ee54aafb739b1cbcaf26a";
logging-data="3414279"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/We+K5vnKZzi4jC7Ygd6A6"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:NVXSHxdMQmv/y8T72MCl+QCBsWA=
 by: Andreas Leitgeb - Fri, 13 Oct 2023 14:57 UTC

I've stumbled over java code, that does an LDAP query, and
sets flag .setReturningObjFlag(true) on the searchControl object.

According to some ressources, like e.g.
https://app.deepsource.com/directory/analyzers/java/issues/JAVA-S1026
this should be avoided, unless the LDAP server and its
data is really trusted.

I'd be curious, what would be the alternatives, under the assumption,
that there are indeed serialized Objects stored in LDAP in whose value
I'm really interested, and if I then didn't want to trust the server
to always return data for the expected objects.

According to description of setReturningObjFlag(): if this flag
is false "... only the name and class of the object is returned",
which to me sounds like I won't get the serialized data.

Do I misunderstand it, or is there no third option besides:
- trust the LDAP-server and have received data immediately deserialized
- not trust the LDAP-server and just not get the data at all.

Is there, maybe, a way to restrict the classes to a whitelist
of classes that it may deserialize, and get an exception on
any attempt to pull in any other class, before that other class
is even initialized?

Is there, maybe, a way to just retrieve the serialized stream and
scrape the relevant info without full deserialization?

Re: LDAP, .setReturningObjFlag(true) and alternatives...

<ugbmum$38ehq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=304&group=comp.lang.java.programmer#304

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: arne@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.lang.java.programmer
Subject: Re: LDAP, .setReturningObjFlag(true) and alternatives...
Date: Fri, 13 Oct 2023 11:15:34 -0400
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <ugbmum$38ehq$1@dont-email.me>
References: <slrnuiimne.9968.avl@logic.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Oct 2023 15:15:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1f3914a744276799d9c414ac3bad6cfd";
logging-data="3422778"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ytH+4zlhbWoSKXt3xZwdXj5Y+RwveXtY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:x2Y0sPs8uG9Wamj/0+FnwDtIbNQ=
In-Reply-To: <slrnuiimne.9968.avl@logic.at>
Content-Language: en-US
 by: Arne Vajhøj - Fri, 13 Oct 2023 15:15 UTC

On 10/13/2023 10:57 AM, Andreas Leitgeb wrote:
> I've stumbled over java code, that does an LDAP query, and
> sets flag .setReturningObjFlag(true) on the searchControl object.
>
> According to some ressources, like e.g.
> https://app.deepsource.com/directory/analyzers/java/issues/JAVA-S1026
> this should be avoided, unless the LDAP server and its
> data is really trusted.
>
> I'd be curious, what would be the alternatives, under the assumption,
> that there are indeed serialized Objects stored in LDAP in whose value
> I'm really interested, and if I then didn't want to trust the server
> to always return data for the expected objects.
>
> According to description of setReturningObjFlag(): if this flag
> is false "... only the name and class of the object is returned",
> which to me sounds like I won't get the serialized data.
>
> Do I misunderstand it, or is there no third option besides:
> - trust the LDAP-server and have received data immediately deserialized
> - not trust the LDAP-server and just not get the data at all.
>
> Is there, maybe, a way to restrict the classes to a whitelist
> of classes that it may deserialize, and get an exception on
> any attempt to pull in any other class, before that other class
> is even initialized?
>
> Is there, maybe, a way to just retrieve the serialized stream and
> scrape the relevant info without full deserialization?

Java deserialization of objects is known to be potential
security problem:
- use all memory
- execute code in readObject method

But I assume your LDAP service is somewhat trusted (as it
its usually provides authentication & authorization!).

So depending on security level you can:
* decide that you trust LDAP and continue to automatic deserialize
* continue to automatic deserialize but find a way to plugin
a deserialization filter (assuming you are on Java 9+ where that
was introduced)
* drop the automatic deserialize and redesign the data transfer
in some way:
- instead of Java object have either JSON or XML and
do a DOM tree parse not a binding to get the data over
in a Java object
- move the info from LDAP to somewhere else like database

Arne

Re: LDAP, .setReturningObjFlag(true) and alternatives...

<slrnuivq4v.1q3b.avl@logic.at>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=305&group=comp.lang.java.programmer#305

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: avl@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.java.programmer
Subject: Re: LDAP, .setReturningObjFlag(true) and alternatives...
Date: Wed, 18 Oct 2023 14:15:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <slrnuivq4v.1q3b.avl@logic.at>
References: <slrnuiimne.9968.avl@logic.at> <ugbmum$38ehq$1@dont-email.me>
Reply-To: avl@logic.at
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 18 Oct 2023 14:15:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="17a0db968e3760d65805191c12117fa2";
logging-data="3887621"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/m47YCznU7C+zBF6Ce4VNZ"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:4UKRHWFzMwdIGq4+jFs3wS8YpQ4=
 by: Andreas Leitgeb - Wed, 18 Oct 2023 14:15 UTC

Arne Vajhøj <arne@vajhoej.dk> wrote:
> On 10/13/2023 10:57 AM, Andreas Leitgeb wrote:
>> https://app.deepsource.com/directory/analyzers/java/issues/JAVA-S1026
>> Do I misunderstand it, or is there no third option besides:
>> - trust the LDAP-server and have received data immediately deserialized
>> - not trust the LDAP-server and just not get the data at all.
>>
>> Is there, maybe, a way to restrict the classes to a whitelist
>> of classes that it may deserialize,
>>
>> Is there, maybe, a way to just retrieve the serialized stream and
>> scrape the relevant info without full deserialization?
>
> Java deserialization of objects is known to be potential
> security problem:
> - use all memory
> - execute code in readObject method

Yes, the root-cause of this topic...

> But I assume your LDAP service is somewhat trusted (as it
> its usually provides authentication & authorization!).

That is correct. This is primarily for learning.
The LDAP server and in particular the element that jndi
wants to eventually deserialize is trusted. But what if
it weren't? ;-)

> So depending on security level you can:
> * decide that you trust LDAP and continue to automatic deserialize
yes, sure.

> * continue to automatic deserialize but find a way to plugin
> a deserialization filter (assuming you are on Java 9+ where that
> was introduced)

Ah, good to know - for future.

> * drop the automatic deserialize and redesign the data transfer
> in some way:
> - instead of Java object have either JSON or XML and
> do a DOM tree parse not a binding to get the data over
> in a Java object
> - move the info from LDAP to somewhere else like database

Not sure if I understand this correctly... is this a way to retrieve
the same data that is already stored in LDAP but in alternative formats,
or do you mean that the data in LDAP needs to be stored in those other
formats(e.g. json) for that to work?

PS: sorry for my late answer... the other problem about slrn and c.l.j.p
strikes again, and I needed to dig out that other machine again, to be
able to check for followups and answer.

Re: LDAP, .setReturningObjFlag(true) and alternatives...

<ugoqu5$3msg8$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=306&group=comp.lang.java.programmer#306

  copy link   Newsgroups: comp.lang.java.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: arne@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.lang.java.programmer
Subject: Re: LDAP, .setReturningObjFlag(true) and alternatives...
Date: Wed, 18 Oct 2023 10:43:17 -0400
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <ugoqu5$3msg8$1@dont-email.me>
References: <slrnuiimne.9968.avl@logic.at> <ugbmum$38ehq$1@dont-email.me>
<slrnuivq4v.1q3b.avl@logic.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 18 Oct 2023 14:43:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="84d47e0ae08b5bc06707cacaca74b78c";
logging-data="3895816"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184/hV8ortDvUn1TETB26SC5SsO9wps/pM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:RnbBbUCBznemNKEBpur0+4k+SrQ=
Content-Language: en-US
In-Reply-To: <slrnuivq4v.1q3b.avl@logic.at>
 by: Arne Vajhøj - Wed, 18 Oct 2023 14:43 UTC

On 10/18/2023 10:15 AM, Andreas Leitgeb wrote:
> Arne Vajhøj <arne@vajhoej.dk> wrote:
>> So depending on security level you can:
>> * decide that you trust LDAP and continue to automatic deserialize
> yes, sure.
>
>> * continue to automatic deserialize but find a way to plugin
>> a deserialization filter (assuming you are on Java 9+ where that
>> was introduced)
>
> Ah, good to know - for future.

Java 9+ docs should have the details.

The short version is:

-Djdk.serialFilter=mypackage.MyClass

which should only allow this specific class to be deserialized.

(there are a ton of other options)

>> * drop the automatic deserialize and redesign the data transfer
>> in some way:
>> - instead of Java object have either JSON or XML and
>> do a DOM tree parse not a binding to get the data over
>> in a Java object
>> - move the info from LDAP to somewhere else like database
>
> Not sure if I understand this correctly... is this a way to retrieve
> the same data that is already stored in LDAP but in alternative formats,
> or do you mean that the data in LDAP needs to be stored in those other
> formats(e.g. json) for that to work?

I am talking about being stored in a different format.

It could solve the deserialization security problem.

And I think there would be other benefits.

Serialized Java objects and what happen if the class
definition changes later is a big topic.

Arne

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor