Skip to content

chore: bring back x-auth-checks with a length limit#19928

Merged
aslilac merged 1 commit into
mainfrom
lilac/bring-back-x-authz-checks
Sep 24, 2025
Merged

chore: bring back x-auth-checks with a length limit#19928
aslilac merged 1 commit into
mainfrom
lilac/bring-back-x-authz-checks

Conversation

@aslilac

@aslilac aslilac commented Sep 23, 2025

Copy link
Copy Markdown
Member

We disabled it before because the header could get too long and cause problems. I've re-enabled it with a maximum length and a comment describing why the length matters. Any results that are truncated will be marked as such. It's not a perfect solution, but this is a useful debugging tool that I want to bring back.

Comment thread coderd/httpapi/authz.go
Comment on lines +36 to +37
checks = checks[:maxHeaderLength]
checks += "<truncated>"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Won't this result in a header that is 2011 bytes long, since maxHeaderLength + len("<truncated>")

Suggested change
checks = checks[:maxHeaderLength]
checks += "<truncated>"
truncationMarker = "<truncated>"
checks = checks[:(maxHeaderLength - len(truncationMarker))]
checks += truncationMarker

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought about that, but figured it wouldn't hurt to let it be a tiny bit longer 😄

@aslilac aslilac merged commit a6fc28c into main Sep 24, 2025
28 checks passed
@aslilac aslilac deleted the lilac/bring-back-x-authz-checks branch September 24, 2025 16:46
Comment thread coderd/httpapi/authz.go

// This is defined separately in slim builds to avoid importing the rbac
// package, which is a large dependency.
func SetAuthzCheckRecorderHeader(ctx context.Context, rw http.ResponseWriter) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could technically find the size of the other headers to, and check how large they are. Then make sure they never exceed 4kb

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants