Skip to content

*: add security enhanced mode part 2#24279

Merged
ti-chi-bot merged 13 commits intopingcap:masterfrom
morgo:security-enhanced-mode-2
Apr 29, 2021
Merged

*: add security enhanced mode part 2#24279
ti-chi-bot merged 13 commits intopingcap:masterfrom
morgo:security-enhanced-mode-2

Conversation

@morgo
Copy link
Contributor

@morgo morgo commented Apr 25, 2021

What problem does this PR solve?

This implements the second of presumably 4 PRs

Problem Summary:

What is changed and how it works?

Proposal: https://github.com/pingcap/tidb/blob/master/docs/design/2021-03-09-security-enhanced-mode.md

What's Changed:

This introduces 2 areas of functionality:

  • Filtering of SHOW STATUS variables.
  • Filtering of infoschema tables.

There are two small updates to the SEM proposal:

  • Because the original privilege name of RESTRICTED_STATUS_VARIABLES_ADMIN exceeds 32 characters I have renamed it to RESTRICTED_STATUS_ADMIN (there is an alternative of changing the table definition, but 32 chars is mysql compatible).

  • A user without process privilege should not be able to see query samples. This will help in the future when the tidb-dashboard connects to the TIDB server to read statements_summary with the DASHBOARD_ADMIN privilege. Removed for now, will handle in a followup PR.

Related changes

Check List

Tests

  • Unit test
  • Manual test:

The tikv status variable only registers with the server when a tikv server is present. To test this, I've had to use a manual test (as well as unit test on the SEM package), but no integration test in TIDB.

Side effects

  • Increased code complexity.
  • Breaking backward compatibility (when enabled; by default it is backward compatible)

Release note

  • The 'Security Enhanced Mode' has been introduced. When enabled, it prevents users with the SUPER privilege from performing certain high risk operations. The design is inspired by Security Enhanced (SE) Linux and AppArmor.

@morgo morgo requested a review from a team as a code owner April 25, 2021 22:47
@morgo morgo requested review from qw4990 and removed request for a team April 25, 2021 22:47
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 25, 2021
@sre-bot
Copy link
Contributor

sre-bot commented Apr 25, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@morgo morgo added the sig/sql-infra SIG: SQL Infra label Apr 25, 2021
@morgo morgo requested review from djshow832 and tiancaiamao April 25, 2021 22:55
@github-actions github-actions bot added the sig/execution SIG execution label Apr 25, 2021
@morgo morgo requested a review from SunRunAway April 28, 2021 02:08
@morgo
Copy link
Contributor Author

morgo commented Apr 28, 2021

@SunRunAway There are a couple of small changes to the proposal doc in this PR. PTAL and make sure you are comfortable with them, thanks!

@SunRunAway
Copy link
Contributor

@SunRunAway There are a couple of small changes to the proposal doc in this PR. PTAL and make sure you are comfortable with them, thanks!

LGTM for these changes!
Cloud you add some descriptions about preventing creating tables in mysql or information_schema db?

* cluster_* tables
* The “instance” column will show the server ID instead of the server IP address.
* statements_summary*
* The query_sample_text will return empty unless the user has the `PROCESS` privilege.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this change may break compatibility.
If a customer does have access to the statements_summary table but does not have PROCESS privilege, they can not read the query_sample_text.

We may discuss whether there is another way to prevent cloudAdmin from accessing the original SQL text.
cc @breeswish

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it might be best to revert this part of the proposal if there is more discussion needed. We can handle in a followup PR instead.

@morgo
Copy link
Contributor Author

morgo commented Apr 28, 2021

Cloud you add some descriptions about preventing creating tables in mysql or information_schema db?

This was covered in a previous update. The sentence is:

The remaining system tables will be limited to read-only operations

@SunRunAway
Copy link
Contributor

Cloud you add some descriptions about preventing creating tables in mysql or information_schema db?

This was covered in a previous update. The sentence is:

The remaining system tables will be limited to read-only operations

How about "The remaining system tables will be limited to read-only operations and can not create new tables"

@bb7133
Copy link
Member

bb7133 commented Apr 29, 2021

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 29, 2021
@tiancaiamao
Copy link
Contributor

/LGTM

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • tiancaiamao

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Details

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 29, 2021
@tiancaiamao
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: 055050f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 29, 2021
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.

rest lgtm

Hostname: "localhost",
AuthUsername: "uroot",
AuthHostname: "%",
}, nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

The test seems not done here?

Copy link
Contributor Author

@morgo morgo Apr 29, 2021

Choose a reason for hiding this comment

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

The comment explains why the test can't work :( The status vars don't install with mocktikv/unistore.

But checking that the permissions are assignable is still valuable, because I discovered an issue when writing this test. The original name for the permission was > 32 characters long, which is not permitted for dynamic privileges.

Co-authored-by: Arenatlx <ailinsilence4@gmail.com>
@SunRunAway
Copy link
Contributor

Cloud you add some descriptions about preventing creating tables in mysql or information_schema db?

This was covered in a previous update. The sentence is:

The remaining system tables will be limited to read-only operations

How about "The remaining system tables will be limited to read-only operations and can not create new tables"

@morgo @tiancaiamao @bb7133 Cloud you solve this before merging this PR?

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Apr 29, 2021
@morgo
Copy link
Contributor Author

morgo commented Apr 29, 2021

Cloud you add some descriptions about preventing creating tables in mysql or information_schema db?

This was covered in a previous update. The sentence is:

The remaining system tables will be limited to read-only operations

How about "The remaining system tables will be limited to read-only operations and can not create new tables"

@morgo @tiancaiamao @bb7133 Cloud you solve this before merging this PR?

I've updated this in 1e8792a

@morgo
Copy link
Contributor Author

morgo commented Apr 29, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: fa92dbb

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 29, 2021
@ti-chi-bot ti-chi-bot merged commit c5ca2ea into pingcap:master Apr 29, 2021
@morgo morgo mentioned this pull request May 19, 2021
10 tasks
@morgo morgo deleted the security-enhanced-mode-2 branch May 31, 2021 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants