-
-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.fasterxml.jackson.core.io; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.net.URI; | ||
import java.net.URL; | ||
import java.nio.charset.Charset; | ||
import java.util.Objects; | ||
|
||
|
@@ -357,6 +360,23 @@ public boolean equals(Object other) | |
if (!(other instanceof ContentReference)) return false; | ||
ContentReference otherSrc = (ContentReference) other; | ||
|
||
// 16-Jan-2022, tatu: As per [core#739] we'll want to consider some | ||
// but not all content cases with real equality: the concern here is | ||
// to avoid expensive comparisons and/or possible security issues | ||
final Object otherRaw = otherSrc._rawContent; | ||
|
||
if (_rawContent == null) { | ||
return (otherRaw == null); | ||
} else if (otherRaw == null) { | ||
return false; | ||
} | ||
|
||
if ((_rawContent instanceof File) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cowtowncoder
Author
Member
|
||
|| (_rawContent instanceof URL) | ||
|| (_rawContent instanceof URI) | ||
) { | ||
return _rawContent.equals(otherRaw); | ||
} | ||
return _rawContent == otherSrc._rawContent; | ||
} | ||
|
||
|
The
URL
andURI
classes arefinal
, butFile
is not. In theory, this means an "attacker" could subclass fromFile
and override theequals
method, thus forcing execution of malicious code. I'm not sure if this is possible in practice, but I would check if the_rawcontent
's class isFile
(notinstanceof
) to avoid any chance of this attack vector becoming possible.