# GHSA-W278-32QG-48Q5: Non-terminal sibling relations can result in incorrect Check responses for a relationship whose expiration time is in the past

- Database: GitHub
- Severity: low (stated by ghsa, no CVSS score)
- Published: 2026-11-10
- Modified: 2026-11-10

## Affected versions

- github.com/authzed/spicedb (Go): from 1.40.0, fixed in 1.57.1

## Description

### Summary

An error in code that optimizes the behavior of SpiceDB checks resulted in expired relationships being included in the computation of permissionship under specific circumstances. When a `relation` was defined as the union (`|`) of a type with expiration (e.g. `foo with expiration`) and that same type with a nonterminal subject relation (e.g. `foo#bar`), a check over that relation would discard the expiration. This could result in incorrect permission checks if the expiration of one of those relationships had passed, up to the time when that relationship is garbage collected.

### Details

One optimization in SpiceDB is that if a check of a particular relationship doesn't require considering the expiration of the relationship, it doesn't include expiration in the datastore query. SpiceDB does a similar optimization if it determines that a caveat isn't involved either.

In the check path, this is computed by [asking whether the count of direct subjects and wildcards without expiration is equal to the total count of direct subjects and wildcards](https://github.com/authzed/spicedb/blob/v1.56.0/internal/graph/check.go#L386). However, the count logic was incorrect for relations whose subject relation matched the type of the relation itself.

For the purposes of this discussion, asking whether the "direct subject" of a relation matches the subject of a check is asking whether the subject of the check matches the type defined in the relation. If you're asking whether a `user` can view a `document` in the check, you're asking whether the type referenced in the relation is exactly `user`.

If we're considering the schema below together with [this code block](https://github.com/authzed/spicedb/blob/v1.56.0/internal/graph/check.go#L341-L355), both `user with expiration` and `user#manager` match the condition defined on [line 341](https://github.com/authzed/spicedb/blob/v1.56.0/internal/graph/check.go#L341), but `user#manager` *should not* be counted as a "direct subject" for this logic. This code was looking at `user with expiration` and saying "that is a direct subject with an expiration" and it was looking at `user#manager` and saying "that is a direct subject without expiration." Instead, it should have been looking at `user#manager` and saying "this is not a direct subject."

This misinterpretation led to the expiration check getting skipped [here](https://github.com/authzed/spicedb/blob/v1.56.0/internal/graph/check.go#L466), and an expired relationship being returned for the check when it should not have been returned.

#### Exposure Window
Postgres and MySQL both run with a 3m GC interval by default. Spanner and CockroachDB both use row-level TTLs which run a cleanup job once daily by default. Outside of your datastore's window you are not affected.

### Proof of concept

This schema:

```zed
use expiration

definition user {
relation manager: user
}

definition document {
relation viewer: user with expiration | user#manager
permission view = viewer
}
```

And this relationship:

```
document:somedoc#viewer@user:alice[expiration:2020-01-01T00:00:00Z]
```

Will result in this check:

```
document:somedoc#view@user:alice
```

returning `HAS_PERMISSION` incorrectly.

### Impact

If all of these apply:
- You have a  `relation` declaration that uses `with expiration`
- It is unioned (`|` operator) with the same type as the `with expiration` type
- That unioned type references a different relation or permission using `#`

Then a check for a permission that references an expired relationship can result in the inclusion of that expired relationship, resulting in an incorrect permission evaluation. See the Proof of Concept for a concrete example.

Reported by Sathwik Yadlapati.

## References

- https://github.com/authzed/spicedb/security/advisories/GHSA-w278-32qg-48q5

Page: https://cve.now/GHSA-W278-32QG-48Q5

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
