Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect and bypass cycles during token revocation #5335

Merged
merged 2 commits into from
Sep 17, 2018
Merged

Conversation

kalafut
Copy link
Contributor

@kalafut kalafut commented Sep 13, 2018

Fixes #4803

@kalafut kalafut added this to the 0.11.2 milestone Sep 13, 2018
@kalafut kalafut mentioned this pull request Sep 14, 2018
vishalnayak
vishalnayak previously approved these changes Sep 14, 2018
if _, seen := seenIDs[child]; !seen {
children = append(children, child)
} else {
ts.Logger().Warn("token cycle found", "token", child)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be best to remove the key that is causing the cycle here, otherwise we will lose all reference to this key and it will live forever

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we delete the key here, the depth-first order is bypassed, which could break references if the whole operation doesn't complete. e.g. if ID root showed up as a child and we deleted it, revoke fails for some reason, now there are possibly tokens with root as an ancestor but root is gone.

But as to whether everything gets cleaned up the way it's written, I think it does:

  1. If the ID is showing up as as "seen", then it was definitely added to the dfs queue (line 1248).
  2. Eventually it was or will be at the front of the queue, with no more of its own children to delete, and it will be deleted.

I'm happy to add tests of any corner cases for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth testing out, I could see a situation where parentPrefix + id + "/" + child is never cleaned up if the child token has the parent encoded incorrectly. Which if we are in this situation is likely.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also i wasn't proposing deleting the whole token here, just the extra parent reference that is causing it to be seen more than once. The previously seen version of the token will still allow for it to be cleaned up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, adding a delete of the parent reference here is a good improvement.

Copy link
Contributor

@briankassouf briankassouf left a comment

Choose a reason for hiding this comment

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

LGTM

@kalafut kalafut merged commit 00314eb into master Sep 17, 2018
@kalafut kalafut deleted the fix-revoke-tree branch September 17, 2018 15:55
@jefferai jefferai restored the fix-revoke-tree branch September 17, 2018 18:10
jefferai added a commit that referenced this pull request Sep 17, 2018
@kalafut kalafut deleted the fix-revoke-tree branch September 19, 2018 21:18
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.

3 participants