question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GraphQL Introspection import fails with NullPointerException

See original GitHub issue

Describe the bug GraphQL schema import fails with confusing error message when the introspection query is not successful.

Specifically, the zap-api-scan.py script failed with this error message:

2021-10-26 16:19:57,787 http://localhost:47065 "GET http://zap/JSON/core/view/urls/ HTTP/1.1" 200 170
2021-10-26 16:19:57,788 Import warnings: internal_error

And the server failed with this NPE stack trace:

2021-10-26 16:58:47,851 [ZAP-ProxyThread-8] ERROR API - Exception while handling API request:
java.lang.NullPointerException: null
        at graphql.introspection.IntrospectionResultToSchema.createSchemaDefinition(IntrospectionResultToSchema.java:68) ~[?:?]
        at org.zaproxy.addon.graphql.GraphQlParser.introspect(GraphQlParser.java:98) ~[?:?]
        at org.zaproxy.addon.graphql.GraphQlApi.importUrl(GraphQlApi.java:109) ~[?:?]
        at org.zaproxy.addon.graphql.GraphQlApi.handleApiAction(GraphQlApi.java:74) ~[?:?]
        at org.zaproxy.zap.extension.api.API.handleApiRequest(API.java:507) [zap-D-2021-08-17.jar:D-2021-08-17]
        at org.parosproxy.paros.core.proxy.ProxyThread.processHttp(ProxyThread.java:497) [zap-D-2021-08-17.jar:D-2021-08-17]
        at org.parosproxy.paros.core.proxy.ProxyThread.run(ProxyThread.java:333) [zap-D-2021-08-17.jar:D-2021-08-17]
        at java.lang.Thread.run(Thread.java:829) [?:?]

I think I see the bug on this line: https://github.com/zaproxy/zap-extensions/blob/0dd3920424e68346e307f73b6cdd226eae9e943e/addOns/graphql/src/main/java/org/zaproxy/addon/graphql/GraphQlParser.java#L98

Looks like if the introspection JSON response has "data": null and attempts to parse the schema, then it throws an exception.

Let me know if I should open this issue elsewhere. The zap-extensions repo wasn’t clear about where issues are managed.

To Reproduce Steps to reproduce the behavior:

  1. Scan a GraphQL endpoint that returns {"data": null} or even {"data": null, "errors": [...]} for a more realistic example.
  2. Logs show the above import failure message
    • It incorrectly normalizes the endpoint and then continues a baseline scan

Expected behavior GraphQL endpoint fails with a clear log message in the scan script. (Not just a NPE inside the container’s file system log.)

Ideally, it would log the full failure message from the GraphQL endpoint. That way it’d be easier to debug and fix the server-side issue.

Software versions

Errors from the zap.log file See above log messages ^

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
ricekotcommented, Oct 27, 2021

Yes, I’ll take a stab at it next week.

3reactions
thc202commented, Oct 28, 2021

For the record, it’s thanks @ricekot 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL Java Annotations recursion issue - Stack Overflow
I am trying to create a recursive schema using GraphQL Java Annotations, but throws an exception. import ...
Read more >
leangen/graphql-spqr - Gitter
Hey, I'm having some issues working out how to use a DataLoader with top level queries. If I have a query that returns,...
Read more >
Schemas | Caliban
A GraphQL schema will be derived automatically at compile-time (no reflection) from the ... Json (custom scalar, need import caliban.interop.play.json._ ) ...
Read more >
Why You Should Disable GraphQL Introspection In Production
Disabling introspection in production is a widely debated topic, ... of trial and error, disabling introspection is a form of security by ...
Read more >
Changelogs | dotCMS
[#22635]; GraphQL introspection queries have been disabled for ... An error that could cause OSGi import procedures to fail has been ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found