Skip to content

NEBULA-4397: Issue with enforcing SafeListing for both internal and external clients#7509

Merged
SimonSapin merged 3 commits intodevfrom
NEBULA-4397
May 19, 2025
Merged

NEBULA-4397: Issue with enforcing SafeListing for both internal and external clients#7509
SimonSapin merged 3 commits intodevfrom
NEBULA-4397

Conversation

@DaleSeo
Copy link
Member

@DaleSeo DaleSeo commented May 16, 2025

A customer reported an issue while using a setup with both internal and external traffic where:

  • They have safelisting enabled for persisted queries
  • They use apollo_persisted_queries::safelist::skip_enforcement in context to bypass safelisting for internal operations
  • They enabled log_unknown to audit which operations would be blocked once fully enforced
  • Even when they skip enforcement for internal operations, the log_unknown feature still logs these operations as "unknown operations"

This is problematic because it makes it difficult to distinguish between:

  • Operations that are truly unknown and will be blocked when enforcement is turned on
  • Internal operations that are deliberately allowed via the skip_enforcement flag

This PR makes changes so that when logging unknown operations, we will include information about whether enforcement was skipped. This will enable the customer to filter their logs and distinguish between truly problematic external operations (where enforcement_skipped is false) and internal operations that are intentionally allowed to bypass safelisting (where enforcement_skipped is true).


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@DaleSeo DaleSeo self-assigned this May 16, 2025
@github-actions
Copy link
Contributor

@DaleSeo, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented May 16, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: c91cd57040ffa1bb06eb0b00

Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

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

I'm a bit confused about how the tests are passing without apollo-router/src/services/layers/persisted_queries/snapshots/apollo_router__services__layers__persisted_queries__tests__pq_layer_freeform_graphql_with_safelist_log_unknown_true@logs.snap being updated — I had to when I was playing with this...

// Note: it's kind of inconsistent that if we require
// IDs and skip_enforcement is set, we don't call
// log_unknown_operation on freeform GraphQL, but if we
// *don't* reuqire IDs and skip_enforcement is set, we
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// *don't* reuqire IDs and skip_enforcement is set, we
// *don't* require IDs and skip_enforcement is set, we

oops, my typo

@DaleSeo
Copy link
Member Author

DaleSeo commented May 16, 2025

I'm a bit confused about how the tests are passing without apollo-router/src/services/layers/persisted_queries/snapshots/apollo_router__services__layers__persisted_queries__tests__pq_layer_freeform_graphql_with_safelist_log_unknown_true@logs.snap being updated — I had to when I was playing with this...

@glasser I also thought it was strange that nothing broke in CI. When I ran cargo test locally, I encountered 4 failing tests. I'm currently struggling to update the snapshots. Just added the updated snapshots.

@DaleSeo DaleSeo requested a review from glasser May 16, 2025 14:45
@DaleSeo DaleSeo marked this pull request as ready for review May 16, 2025 14:46
@DaleSeo DaleSeo requested a review from a team May 16, 2025 14:46
@DaleSeo DaleSeo changed the title [NEBULA-4397] Issue with enforcing SafeListing for external clients NEBULA-4397: Issue with enforcing SafeListing for both internal and external clients May 16, 2025
level: INFO
message: Loaded 2 persisted queries.
- fields:
enforcement_skipped: false

Choose a reason for hiding this comment

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

It's a problem that this test passes when the snapshot doesn't match. This indicates something is wrong with the assert_snapshot_subscriber implementation. This needs to be fixed - if it isn't done as part of this PR, then the router team should investigate separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pubmodmatt Good callout! I’ve submitted a ticket with the router team to investigate it separately.

@DaleSeo DaleSeo requested review from pubmodmatt and swcollard May 16, 2025 16:27
@SimonSapin SimonSapin merged commit 0b3f140 into dev May 19, 2025
15 checks passed
@SimonSapin SimonSapin deleted the NEBULA-4397 branch May 19, 2025 13:02
@abernix
Copy link
Member

abernix commented May 20, 2025

@Mergifyio backport 1.x

@mergify
Copy link
Contributor

mergify bot commented May 20, 2025

backport 1.x

✅ Backports have been created

Details

@abernix
Copy link
Member

abernix commented May 23, 2025

Note: This PR never had a changeset written for it, which is a miss!

@lrlna lrlna mentioned this pull request Jun 2, 2025
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

Successfully merging this pull request may close these issues.

6 participants