etcd icon indicating copy to clipboard operation
etcd copied to clipboard

AuthStore::Recover is not invalidating caches.

Open ptabor opened this issue 3 years ago • 3 comments

What happened?

No repro in practice yet attempted. Adding FTR.

The method: https://github.com/etcd-io/etcd/blob/a08d479463960948d5d9c3508623ade915c6e66f/server/auth/store.go#L374

is used when a new snapshot is received over raft (e.g. server was lagging).

The method is not invalidating: https://github.com/etcd-io/etcd/blob/a08d479463960948d5d9c3508623ade915c6e66f/server/auth/store.go#L237

This creates risk that data server read out of the cache might be stale (e.g. permission got revoked in the 'meantime') but the cache is missing updates skipped in the WAL log application (because it loaded a fresher snapshot).

What did you expect to happen?

Reinitialize the cache.

How can we reproduce it (as minimally and precisely as possible)?

We need a test that will:

  • run 3 etcd instances
  • grant some permissions on ranges
  • diconnect a single member
  • revoke the permissions
  • commit a lot of transactions (or force the disconnected member run out of log horizont)
  • reconnect the member... the member is expected to download the snapshot...
  • check whether the member revokes the access to the given key-range.

Anything else we need to know?

No response

Etcd version (please run commands below)

Spotted in the main tree. But the logic was rather not changed recently.

Etcd configuration (command line flags or environment variables)

No response

Etcd debug information (please run commands blow, feel free to obfuscate the IP address or FQDN in the output)

No response

Relevant log output

No response

ptabor avatar Apr 05 '22 08:04 ptabor

@ptabor Thanks for figuring out this. I'll try to reproduce and analyze related code this weekend.

mitake avatar Apr 06 '22 15:04 mitake

@ptabor I'm still trying to reproduce, but invalidating rangePermCache in authStore.Recover() is fine and good for defensive purpose. I'll open a PR for the change.

mitake avatar Apr 10 '22 13:04 mitake

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 12:07 stale[bot]

Fixed with https://github.com/etcd-io/etcd/pull/14358

serathius avatar Oct 27 '23 10:10 serathius