Skip to content

lib-oauth2: jwt - Avoid use-after-realloc of jwt_node front pointer#289

Open
rootvector2 wants to merge 1 commit into
dovecot:mainfrom
rootvector2:lib-oauth2-jwt-nodes-realloc
Open

lib-oauth2: jwt - Avoid use-after-realloc of jwt_node front pointer#289
rootvector2 wants to merge 1 commit into
dovecot:mainfrom
rootvector2:lib-oauth2-jwt-nodes-realloc

Conversation

@rootvector2
Copy link
Copy Markdown
Contributor

oauth2_jwt_copy_fields() captures subroot from array_front(&nodes)
then calls array_append_space(&nodes) inside the inner loop. When the
append cannot extend the buffer in place it relocates it, so subroot
aliases the previous slot and later subroot->prefix / subroot->array
reads operate on the abandoned location. Copy the front node by value
before the append.

oauth2_jwt_copy_fields() takes subroot via array_front(&nodes) and
then calls array_append_space(&nodes) inside the inner loop. When the
append cannot extend the nodes buffer in place, it relocates the
buffer, leaving the captured subroot pointer aliasing the previous
slot; subsequent reads of subroot->prefix and subroot->array end up
operating on the abandoned location. Copy the front node by value
before the append so the prefix/array references remain valid.
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.

1 participant