Skip to content

[iOS] Heap buffer overflow in ProtoWriter.swift when writing messages with more than 5 layers of nesting #3202

Description

@amorde

While running with the Address Sanitizer enabled I found a buffer overflow in ProtoWriter.swift.

Image

Image

The issue is the + 1 in the failing line combined with the fact that the caller increments the index immediately before:

messageStackIndex += 1
if messageStackIndex >= messageStackCapacity {
expandMessageStack()
}

It attempts to copy and deinitialize memory that has not been initialized in the source buffer, specifically out of bounds by 1.

I've written a test that can reproduce this with the address sanitizer enabled and will open a PR with it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions