Skip to content

JSON Smart Security Vulnerability #676

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

Closed
bperino opened this issue Mar 12, 2021 · 8 comments
Closed

JSON Smart Security Vulnerability #676

bperino opened this issue Mar 12, 2021 · 8 comments

Comments

@bperino
Copy link

bperino commented Mar 12, 2021

JSON Smart has not been updated in a long time and has a security vulnerability associated with it: https://nvd.nist.gov/vuln/detail/CVE-2021-27568

Please allow us to exclude JSON Smart and use a different provider.

@exabrial
Copy link

exabrial commented Mar 15, 2021

Please allow us to exclude JSON Smart and use a different provider.

It's already possible :) see here: https://github.com/json-path/JsonPath/blob/master/README.md#jsonprovider-spi

To exclude it from your application, simply perform an mvn dependenecy:tree. You would see this:

[INFO] +- com.jayway.jsonpath:json-path:jar:2.5.0:compile
[INFO] |  \- net.minidev:json-smart:jar:2.3:compile
[INFO] |     \- net.minidev:accessors-smart:jar:1.2:compile
[INFO] |        \- org.ow2.asm:asm:jar:5.0.4:compile

then you can exclude it in your pom.xml:

		<dependency>
			<groupId>com.jayway.jsonpath</groupId>
			<artifactId>json-path</artifactId>
			<version>2.5.0</version>
			<scope>compile</scope>
			<exclusions>
				<exclusion>
					<groupId>net.minidev</groupId>
					<artifactId>json-smart</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

If possible, I would submit a PR removing or upgrading JSON Smart support to help the author out.

@bperino
Copy link
Author

bperino commented Mar 15, 2021

That indeed did work. Interesting issue we ran into on our side though. It looks like Spring tries to decorate its message converters with JsonPath if it finds it on the classpath. I had to override the configuration class to prevent this:

public class SpringDataWebConfiguration {

  @Override
  public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
  
	  if (ClassUtils.isPresent("com.jayway.jsonpath.DocumentContext", context.getClassLoader())
			  && ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", context.getClassLoader())) {
  
		  ObjectMapper mapper = getUniqueBean(ObjectMapper.class, context, ObjectMapper::new);
  
		  ProjectingJackson2HttpMessageConverter converter = new ProjectingJackson2HttpMessageConverter(mapper);
		  converter.setBeanFactory(context);
		  forwardBeanClassLoader(converter);
  
		  converters.add(0, converter);
	  }
  
	  if (ClassUtils.isPresent("org.xmlbeam.XBProjector", context.getClassLoader())) {
  
		  converters.add(0, context.getBeanProvider(XmlBeamHttpMessageConverter.class) //
				  .getIfAvailable(() -> new XmlBeamHttpMessageConverter()));
	  }
  }
}

Source https://github.com/spring-projects/spring-data-commons/blob/master/src/main/java/org/springframework/data/web/config/SpringDataWebConfiguration.java#L162

@erlioniel
Copy link

@exabrial thank you for the code snippet, it's working like a charm, however have a few comments about it:

  1. Maybe it's worth to mention it in the documentation section?
  2. I would actually prefer if jsonpath will go without any json-parsing library and will dynamically check if there any library available to use, instead requiring manual configuration & selection of json provider. Could you please share a reason why the current solution was preferred?

@r0bb3n
Copy link

r0bb3n commented Apr 3, 2021

I'd like to add, that the json-smart project is (again) searching for new maintainer, see the update here and the indicating comment on the CVE-2021-27568 fixing issue.
Maybe it is worth to consider a switch to a different default library with larger community?

@UrielCh
Copy link

UrielCh commented Apr 3, 2021

just release:

  • json-smart-action 2.4.1
  • json-smart 2.4.1
  • minidev-parent 2.4.1
  • accessors-smart 1.3

All versions number increased.
no more JUnit 4, I use JUnit 5

@UrielCh
Copy link

UrielCh commented Apr 4, 2021

JSON-smart is now maintained, for a week or two.

if you have some requests, do them quickly.

CVE-2021-27568 is fixed for JSON-SMART V2

@rajivbandi
Copy link

rajivbandi commented Apr 5, 2021

Does this mean that a Json Path release of v2.6.0 would include JSON-smart v2.4.1 where the CVE is fixed ?
If yes, when can we expect the Json Path release?

@kallestenflo
Copy link
Contributor

Fixed in 2.6.0

mkr added a commit to mkr/JsonPath that referenced this issue Apr 13, 2023
…lso related to json-path#682, json-path#676, json-path#513, json-path#252)

* Replace hard-coded json-smart parser with one retrieved from context (where available) or default configuration.
* This enables a project to _exclude_ the transitive json-smart dependency when setting an alternative default configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants