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

server,session: code refactor for multiple statements in one query #16056 #22451

Merged
merged 7 commits into from
Jan 26, 2021

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Forbidden multiple statements to ease the security problem described here https://github.com/pingcap/tidb-test/issues/1152

This PR ports the code of #16056 to release-4.0, and also part of #17678 to clean up the code.

PS: To fix the point get DATA RACE in #18145, I try to avoid cherry-pick too many PRs and wrote:

A correct fix need to cherry pick a series of commits:

#16056
#17555
#17593
#17678
#17911

That maybe too much for 4.0

Ironically, most of those refactoring PRs are cherry-picked to release-4.0 to get the "correct fix" in the end.

Problem Summary:

See https://github.com/pingcap/tidb-test/issues/1152

What is changed and how it works?

What's Changed:

Execute is deprecated, use ExecuteStmt instead.

How it Works:

The Execute() API can execute multiple statements from one query string, an attacker can leverage that to ingest arbitrarily SQL through this API.

The ExecuteStmt() API allows only one statement, it's safer than Execute().

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Breaking backward compatibility

API change, Execute is deprecated.

Release note

  • code refactor for multiple statements in one query

@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Jan 20, 2021
@tiancaiamao tiancaiamao added the security Everything related with security label Jan 21, 2021
@morgo
Copy link
Contributor

morgo commented Jan 25, 2021

LGTM

@ti-srebot
Copy link
Contributor

@morgo, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. See the corresponding SIG page for more information. Related SIG: sql-infra(slack).

@tiancaiamao tiancaiamao requested a review from lysu January 25, 2021 03:08
@tiancaiamao
Copy link
Contributor Author

PTAL @lysu @jackysp @coocood

@lysu
Copy link
Contributor

lysu commented Jan 25, 2021

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 25, 2021
Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 25, 2021
ti-srebot
ti-srebot previously approved these changes Jan 25, 2021
@xhebox
Copy link
Contributor

xhebox commented Jan 25, 2021

/merge

@ti-srebot
Copy link
Contributor

Sorry @xhebox, this branch cannot be merged without an approval of release maintainers.

@tiancaiamao
Copy link
Contributor Author

/merge

@ti-srebot
Copy link
Contributor

Sorry @tiancaiamao, this branch cannot be merged without an approval of release maintainers.

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Jan 25, 2021
AilinKid
AilinKid previously approved these changes Jan 25, 2021
@AilinKid
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor

Sorry @AilinKid, this branch cannot be merged without an approval of release maintainers.

@AilinKid
Copy link
Contributor

@bb7133

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot removed the status/LGT3 The PR has already had 3 LGTM. label Jan 26, 2021
@ti-srebot ti-srebot added the status/LGT4 The PR has already had 4 LGTM. label Jan 26, 2021
@bb7133
Copy link
Member

bb7133 commented Jan 26, 2021

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 26, 2021
@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 21714
  • 21957
  • 21471
  • 21504
  • 21550

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 084bf06 into pingcap:release-4.0 Jan 26, 2021
@tiancaiamao tiancaiamao deleted the security branch January 28, 2021 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security Everything related with security sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT4 The PR has already had 4 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants