Skip to content

Fix union index out of boundary issue #33022

Closed
HarryLeeIBM wants to merge 3 commits intoClickHouse:masterfrom
ClibMouse:Issue80
Closed

Fix union index out of boundary issue #33022
HarryLeeIBM wants to merge 3 commits intoClickHouse:masterfrom
ClibMouse:Issue80

Conversation

@HarryLeeIBM
Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category:

  • Bug Fix

Changelog entry:

Fixed Apache Avro Union type index out of boundary issue in Apache Avro binary format.

Detailed description / Documentation draft:

ClickHouse supports input and output in the Apache Avro format. When deserializing this data, the file format can specify a series of actions to resolve the schema of the data. While handling a Union action, ClickHouse fails to ensure that decoded index value is within bounds of the collection of actions to be performed. Attacker can put an out-of-bound index in Union type which can crash ClickHouse.

The fix is to add the boundary checking code to ensure index is in safe range otherwise exception will be thrown.

The fix also includes a functional test which uses an Avro test file in binary format. The test file is copied from existing nested_complex.avro except it has an incorrect index(2 instead of 1) of Union type which would crash ClickHouse without the fix.

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Dec 21, 2021
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 21, 2021

CLA assistant check
All committers have signed the CLA.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Dec 21, 2021

namespace DB
{
namespace ErrorCodes
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 should put only used ErrorCodes in .h and in .cpp files.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pushed new commit as per your comments.

@alexey-milovidov alexey-milovidov self-assigned this Dec 21, 2021
@alexey-milovidov alexey-milovidov added can be tested Allows running workflows for external contributors and removed can be tested Allows running workflows for external contributors labels Dec 22, 2021
@mreddy017 mreddy017 force-pushed the Issue80 branch 3 times, most recently from 2ecb426 to 3044483 Compare December 22, 2021 20:33
@alexey-milovidov alexey-milovidov mentioned this pull request Dec 22, 2021
alexey-milovidov added a commit that referenced this pull request Dec 23, 2021
@alexey-milovidov
Copy link
Copy Markdown
Member

Merged here: #33022

robot-clickhouse pushed a commit that referenced this pull request Dec 23, 2021
robot-clickhouse pushed a commit that referenced this pull request Dec 23, 2021
robot-clickhouse pushed a commit that referenced this pull request Dec 23, 2021
robot-clickhouse pushed a commit that referenced this pull request Dec 23, 2021
robot-clickhouse pushed a commit that referenced this pull request Dec 23, 2021
alexey-milovidov added a commit that referenced this pull request Dec 23, 2021
alexey-milovidov added a commit that referenced this pull request Dec 23, 2021
alexey-milovidov added a commit that referenced this pull request Dec 23, 2021
alexey-milovidov added a commit that referenced this pull request Dec 23, 2021
alexey-milovidov added a commit that referenced this pull request Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants