Skip to content

Ledger-configured f:defaultAllow false does not apply to requests carrying no policy inputs (and reads/writes disagree) #1640

Closed

Description

@aaj3f

A ledger configured f:defaultAllow false still serves every row to an anonymous reader, and the read and write paths disagree about it in a way I think is worth fixing — or at minimum documenting clearly, because the disagreement produces a false "my config is working" signal.

I want to frame this as a design question rather than a bug report. The current behavior is deliberate at each individual gate; it's the combination that surprises.

What happens

On a ledger whose config graph declares f:defaultAllow false, with a request carrying no identity, no policy-class, and no inline policy (verified over HTTP against /v1/fluree/query and /v1/fluree/insert):

Ledger config Anonymous read Anonymous write
f:defaultAllow false alone returns every row succeeds (200)
f:defaultAllow false + f:policyClass returns every row denied (400, "Policy enforcement prevents modification.")

The second row is the uncomfortable one. An operator who configures both — which is the shape our own docs use in their examples — gets a loud, clearly-correct denial on writes, and no enforcement whatsoever on reads. Writes being denied is exactly the positive control someone would use to convince themselves the config took effect.

Mechanism

The two paths consult config in the opposite order relative to their enforcement gate.

Reads gate before merging. apply_source_or_global_policy (fluree-db-api/src/query/connection.rs:1080) calls wrap_policy only when global_opts.has_any_policy_inputs() is true, and that's the raw request opts — merge_policy_opts, which folds in the ledger's f:defaultAllow / f:policyClass, runs inside wrap_policy (fluree-db-api/src/view/fluree_ext.rs:707). So for a request with no policy inputs the config is never consulted and no PolicyContext is built at all. Not "a context with default-allow true" — no policy object.

Writes merge before gating. build_transact_policy_context merges config first (fluree-db-api/src/policy_view.rs:369) and only then checks effective_opts.has_any_policy_inputs() (:439). A config-supplied f:policyClass lands in the merged opts and flips that predicate, so a context gets built and f:defaultAllow false governs — hence the 400.

That also explains why f:defaultAllow false alone doesn't lock writes: it merges in, but a bare default-deny isn't itself treated as a request for enforcement, so the predicate stays false and the transaction runs unrestricted.

Current read behavior is pinned in anonymous_request_unenforced_despite_config_default_allow_false (fluree-db-api/tests/it_config_graph.rs).

Why this is more pointed after #1625

#1625 makes GovernanceOptions.default_allow tri-state so a configured f:defaultAllow true actually reaches identity-carrying requests (previously merely supplying an identity read as an implicit override back to deny). After it lands, f:defaultAllow can open a ledger but still can't close one:

Ledger config Anonymous Identity-carrying
f:defaultAllow true sees everything sees everything (fixed by #1625)
f:defaultAllow false sees everything sees only schema triples

Half of the setting starts behaving the way operators expect, which makes it more reasonable — not less — to assume the other half does too.

Docs currently promise the opposite

docs/ledger-config/setting-groups.md:41 says config-declared f:policyClass / f:defaultAllow defaults "apply to transactions even when the request itself carries no policy inputs." For transactions with a configured f:policyClass that's true; for reads it isn't, and the sentence reads as a general guarantee.

Relatedly, setting-groups.md:13 and :20 give the Policy system default as f:defaultAllow true and call an unconfigured ledger "fully open," while docs/security/policy-model.md:246 documents default-allow: false as fail-closed and recommended for production. Both are defensible depending on whether a request carries an identity, but stated flatly they contradict each other.

Open questions

  1. Should f:defaultAllow false engage enforcement for an otherwise-anonymous request? The operator-intent reading says yes — the config is the ledger's own posture, and a request shouldn't escape it by saying nothing. The cost is that any existing ledger carrying a config with f:defaultAllow false would flip from fully-open to schema-only for anonymous reads with no client change. That's the fix working as intended, but it needs a prominent release note.

  2. If yes, what should "enforced anonymous" mean? With the existing is_root computation (fluree-db-api/src/policy_builder.rs:465-471), a non-root context with an empty restriction set and default_allow: false denies every non-schema flake, so the caller sees ontology triples and nothing else (schema flakes bypass policy unconditionally — fluree-db-policy/src/schema.rs:72-80). Is "200 with schema only" right, or should an unauthenticated request against a closed ledger be refused outright? I lean toward the former, for consistency with how a fully-denied identity is already treated, but it should be a deliberate choice.

  3. Should the read and write paths be reconciled regardless of how 1 lands? Even leaving anonymous reads open, having one path gate on pre-merge opts and the other on post-merge opts is the kind of divergence that produces exactly this class of surprise. Making the gate order consistent may be worth doing on its own.

  4. Where does the decision live? Today the gate is a pure function of the request. Letting config participate means the decision to build a context — not merely its default — has to consult resolved config, which is a different shape from merge_policy_opts filling defaults in afterwards. There's also OverrideControl to think about, and whether server-level config should participate the same way.

  5. How would a deployment that wants "anonymous reads allowed, identities enforced" express that once false means locked? Presumably a policy granting to everyone — but I'd want to confirm there's a real spelling for that and document it. If there isn't, the design has a hole.

Happy to take the implementation once 1–3 are settled; the tri-state plumbing from #1625 is the natural foundation.

Activity

  1. added
    triage:needs-decision
    P1
    area:server
    on Aug 25, 2026
  2. bplatz commented on Sep 26, 2026

    @bplatz
    Contributor

    Resolved by #1804 (merged 2026-09-11, commits 61cadaf / b2542da), which didn't reference this issue.

    Reads: a request with no policy inputs now routes through wrap_policy_defaults, which applies the ledger's f:defaultAllow / f:policyClass whenever the config graph declares a policy group. Connection, dataset, SPARQL, stream, Bolt and GraphQL reads all take it. Unconfigured ledgers remain open.

    Writes: has_any_policy_inputs() now counts default_allow == Some(false), so a merged-in f:defaultAllow false alone engages enforcement on an anonymous write. f:policyClass is no longer needed alongside it. Read and write both merge config before gating.

    How the open questions landed:

    1. Yes: config governs anonymous requests.
    2. Enforced anonymous is 200 with schema triples only, not an outright refusal.
    3. Reconciled: both paths gate on post-merge options.

    The old pin was flipped to anonymous_request_enforces_config_default_allow_false (fluree-db-api/tests/it_config_graph.rs), which passes. The write side was checked by calling build_transact_policy_context (what the consensus write path calls every transaction) with empty governance. It returns a non-root context for a f:defaultAllow false ledger and none for an unconfigured one.

    Residue, not blocking closure:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:servertriage:needs-decision

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions