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) #54052

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

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@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. labels Jun 17, 2024
@ti-chi-bot ti-chi-bot added the type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. label Jun 17, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 17, 2024
@lcwangchao lcwangchao force-pushed the cherry-pick-54032-to-release-7.5 branch from 3b03c7a to fac56a5 Compare June 17, 2024 10:29
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-7.5@1563cc5). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.5     #54052   +/-   ##
================================================
  Coverage               ?   72.0204%           
================================================
  Files                  ?       1411           
  Lines                  ?     410750           
  Branches               ?          0           
================================================
  Hits                   ?     295824           
  Misses                 ?      95025           
  Partials               ?      19901           
Flag Coverage Δ
unit 72.0204% <100.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9913% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 53.4573% <0.0000%> (?)

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 18, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label 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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 18, 2024
Copy link

ti-chi-bot bot commented Jun 18, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-18 06:56:54.059392662 +0000 UTC m=+97940.544881486: ☑️ agreed by lcwangchao.
  • 2024-06-18 07:11:58.862417982 +0000 UTC m=+98845.347906816: ☑️ agreed by CbcWestwolf.

@ti-chi-bot ti-chi-bot bot merged commit d179476 into pingcap:release-7.5 Jun 18, 2024
18 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-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants