Skip to content

authz: viewable_environments defined only in the data document is treated as undefined (fails open) #6571

Closed

Description

@markphelps

Summary

Since #6567, the Rego engine decides whether a policy defines the optional viewable_environments scope by looking for a rule with that name in the parsed .rego module (internal/server/authz/engine/rego/engine.go, updatePolicy).

The query x = data.flipt.authz.v2.viewable_environments can also be answered by a data document at flipt.authz.v2.viewable_environments in the authz data source, with no rule in the policy.

Behavior

Scope defined in Before #6567 After #6567
Policy rule filtered filtered
Data document only filtered unrestricted (nil → ["*"])
Nowhere unrestricted unrestricted

For the data-only setup, ListEnvironments now returns every environment. It fails open.

viewable_namespaces is not affected: it is a function, so it can't come from data.

Possible fixes

  • Treat the scope as defined when either the module has the rule or the store has a document at that path. The store can change on data reload, so check it at eval time or when updateData runs.
  • Or document that viewable_environments must be defined as a rule in the policy, and warn when a data document exists at that path without one.

Tests

Add an engine test that sets viewable_environments only through the data source and checks that the returned scope is filtered, not nil.

Activity

  1. github-actions commented on Sep 24, 2026

    @github-actions
    Contributor

    Issue Health Check: Well scoped

    Type: Bug report

    This is a well-scoped bug report that clearly identifies a regression in the Rego authorization engine. The author provides a precise behavior matrix, the affected code path, and two concrete fix options, making the issue immediately actionable.

    Thanks — this issue looks well scoped and ready for the maintainers to evaluate.

    Need help with Flipt? Support the project through GitHub Sponsors or learn about Flipt Pro.

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

    Type

    No type

    Projects

    • Status
      Done
    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions