Skip to content

Conversation

@deepgarg760
Copy link
Collaborator

Summary

This PR adds a configuration flag to disable the GraphiQL endpoint and implements Content Security Policy (CSP) headers to address security scanner findings. This resolves blockers for air-gapped deployments and satisfies OWASP ZAP security requirements.

Changes

1. Feature Flag for GraphiQL Endpoint

  • Added @ConditionalOnProperty annotation to GraphiQLController
  • Endpoint can now be disabled via configuration: graphql.graphiql.enabled=false
  • Defaults to true for backward compatibility
  • When disabled, endpoint returns HTTP 404

2. Security Headers Implementation

  • Content-Security-Policy: Restricts resource loading to trusted sources
    • script-src 'self' https://unpkg.com 'unsafe-inline'
    • style-src 'self' https://unpkg.com 'unsafe-inline'
    • img-src 'self' data:
    • connect-src 'self'
  • X-Content-Type-Options: nosniff: Prevents MIME-sniffing attacks
  • X-Frame-Options: DENY: Prevents clickjacking attacks

3. Configuration Updates

  • Added graphql.graphiql.enabled property in application.yaml
  • Environment variable: GRAPHQL_GRAPHIQL_ENABLED
  • Documentation added to configuration file

4. Dependency Updates

  • Added spring-boot-autoconfigure dependency to support @ConditionalOnProperty
  • Updated Gradle lock file with new dependencies

Use Cases

Air-Gapped Deployments

Customers in air-gapped environments can now disable the GraphiQL endpoint that requires external CDN access:

export GRAPHQL_GRAPHIQL_ENABLED=false

Production Security

Organizations can disable developer tools in production:

graphql:
  graphiql:
    enabled: false

Security Compliance

CSP headers now satisfy security scanner requirements (OWASP ZAP, Burp Suite, etc.)

Testing

  • ✅ Compilation successful
  • ✅ Code formatting applied (Spotless)
  • ✅ Dependency lock file updated
  • ✅ Backward compatible (defaults to enabled)

Files Modified

  • metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphiQLController.java
  • metadata-service/configuration/src/main/resources/application.yaml
  • metadata-service/graphql-servlet-impl/build.gradle
  • metadata-service/graphql-servlet-impl/gradle.lockfile

Related Issues

Addresses security and air-gapped deployment concerns mentioned in internal discussions.

🤖 Generated with Claude Code

@github-actions github-actions bot added the devops PR or Issue related to DataHub backend & deployment label Nov 20, 2025
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Nov 20, 2025
Adds configuration to disable GraphiQL in air-gapped/production environments
and implements Content Security Policy headers to address security scanner findings.

Changes:
- Add @ConditionalOnProperty to GraphiQLController for enabling/disabling endpoint
- Add graphql.graphiql.enabled configuration property (defaults to true for backward compatibility)
- Implement CSP headers (script-src, style-src, connect-src, img-src)
- Add X-Content-Type-Options and X-Frame-Options security headers
- Add spring-boot-autoconfigure dependency and update gradle lockfile

Configuration:
- Set GRAPHQL_GRAPHIQL_ENABLED=false to disable in air-gapped or production environments
- Endpoint returns 404 when disabled

Security improvements:
- Content-Security-Policy header allows self and unpkg.com sources
- X-Content-Type-Options: nosniff prevents MIME-sniffing attacks
- X-Frame-Options: DENY prevents clickjacking

Resolves air-gapped deployment blockers and satisfies OWASP ZAP security requirements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@deepgarg760 deepgarg760 requested review from david-leifker and esteban and removed request for david-leifker November 20, 2025 06:46
Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes enough sense, but not sure about the CSP headers

Comment on lines +45 to +61
() -> {
// Add Content Security Policy headers to allow unpkg.com for external resources
response.setHeader(
"Content-Security-Policy",
"default-src 'self'; "
+ "script-src 'self' https://unpkg.com 'unsafe-inline'; "
+ "style-src 'self' https://unpkg.com 'unsafe-inline'; "
+ "img-src 'self' data:; "
+ "connect-src 'self'");

response.setHeader("X-Content-Type-Options", "nosniff");
response.setHeader("X-Frame-Options", "DENY");

return this.graphiqlHtml;
},
this.getClass().getSimpleName(),
"graphiQL");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't feel confident about these changes and what they're doing for us. i would recommend double checking with someone from the platform team

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are not mandatory but are required to satisfy the security compliance issue for enterprise customers. Security scanners like OWASP flag the lack of CSP headers and reported them as security vulnerability.
This has been reported in community slack.
https://datahubspace.slack.com/archives/CV2KB471C/p1762287974158799?thread_ts=1761770048.446169&cid=CV2KB471C

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Nov 20, 2025
@datahub-cyborg datahub-cyborg bot added pending-submitter-merge and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops PR or Issue related to DataHub backend & deployment pending-submitter-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants