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

privilege: fix auth_socket bug, should only allow os user name to login (#54032) #54049

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #54032

What problem does this PR solve?

Issue Number: close #54031

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. my os user is wangchao
$ whoami
wangchao
  1. create users:
> CREATE USER 'u1'@'localhost' IDENTIFIED WITH auth_socket;
Query OK, 0 rows affected
Time: 0.017s
> CREATE USER 'u2'@'localhost' IDENTIFIED WITH auth_socket AS "wangchao";
Query OK, 0 rows affected
Time: 0.012s
> CREATE USER 'wangchao'@'localhost' IDENTIFIED WITH auth_socket;
Query OK, 0 rows affected
Time: 0.025s
TiDB root@127.0.0.1:test> select host,user,authentication_string,plugin from mysql.user;
+-----------+----------+-----------------------+-----------------------+
| host      | user     | authentication_string | plugin                |
+-----------+----------+-----------------------+-----------------------+
| %         | root     |                       | mysql_native_password |
| localhost | u1       |                       | auth_socket           |
| localhost | u2       | wangchao              | auth_socket           |
| localhost | wangchao |                       | auth_socket           |
+-----------+----------+-----------------------+-----------------------+
4 rows in set
Time: 0.011s
  1. Try log in:

u1 is rejected because it is not same with os user:

$ mysql --comments -uu1 -S/tmp/tidb-4001.sock
ERROR 1045 (28000): Access denied for user 'u1'@'localhost' (using password: YES)

u2 is allowed because its authenticate string is same with os user:

$ mysql --comments -uu2 -S/tmp/tidb-4001.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2097182
Server version: 8.0.11-TiDB-None TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
...

wangchao is allowed because its the os user name:

> mysql --comments -uwangchao -S/tmp/tidb-4001.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2097184
Server version: 8.0.11-TiDB-None TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
...
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

fix `auth_socket` bug, should only allow os user name to login

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Jun 17, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 17, 2024
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 17, 2024
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-6.5@abf2386). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-6.5     #54049   +/-   ##
================================================
  Coverage               ?   73.6343%           
================================================
  Files                  ?       1096           
  Lines                  ?     352220           
  Branches               ?          0           
================================================
  Hits                   ?     259355           
  Misses                 ?      76183           
  Partials               ?      16682           

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 18, 2024
Copy link

ti-chi-bot bot commented Jun 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CbcWestwolf, lcwangchao

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [CbcWestwolf,lcwangchao]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 18, 2024
Copy link

ti-chi-bot bot commented Jun 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-18 06:57:17.031333714 +0000 UTC m=+97963.516822547: ☑️ agreed by lcwangchao.
  • 2024-06-18 07:10:59.411289553 +0000 UTC m=+98785.896778386: ☑️ agreed by CbcWestwolf.

@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 20, 2024
@ti-chi-bot ti-chi-bot bot merged commit 4ffd88c into pingcap:release-6.5 Jun 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants