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

Block some specific characters in module command names #11434

Merged

Conversation

enjoy-binbin
Copy link
Collaborator

@enjoy-binbin enjoy-binbin commented Oct 25, 2022

Today we don't place any specific restrictions on module command names.
This can cause ambiguous scenarios. For example, someone might name a
command like "module|feature" which would be incorrectly parsed by the
ACL system as a subcommand.

In this PR, we will block some chars that we know can mess things up.
Specifically ones that can appear ok at first and cause problems in some
cases (we rather surface the issue right away).

There are these characters:

  • (space) - issues with old inline protocol.
  • \r, \n (newline) - can mess up the protocol on acl error replies.
  • | - sub-commands.
  • @ - ACL categories
  • =, , - info and client list fields.

note that we decided to leave : out as it's handled by getSafeInfoString and is more likely to already been used by existing modules.

This is a breaking change, closes #11390.

Today we don't place any specific restrictions on module command names.
This can cause ambiguous scenarios. For example, someone might name a
command like "module|feature" which would be incorrectly parsed by the
ACL system as a subcommand.

In this PR, we will block some chars that we know can mess things up.
Specifically ones that can appear ok at first and cause problems in some
cases (we rather surface the issue right away).

There are these characters:
- `\r`, `\n` (newline) - can mess up the protocol on acl error replies
- ` ` (space) - issues with old inline protocol
- `|` - sub-commands
- `@` - ACL
- `=` - info commandstats
- `:` - info commandstats
- `,` - info commandstats
src/sds.c Outdated Show resolved Hide resolved
src/module.c Outdated Show resolved Hide resolved
tests/modules/subcommands.c Outdated Show resolved Hide resolved
src/sds.c Outdated Show resolved Hide resolved
src/module.c Outdated Show resolved Hide resolved
src/sds.c Outdated Show resolved Hide resolved
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

LGTM. just need to decide when we release it. arguably we can make it part of 7.2.
@redis/core-team please advise.
in theory this is a breaking change, but i suppose we can assume (hope) that there are no modules who actually use any of these characters in reality?
i guess it's safe to say about all the chars in that list, maybe except for :?

src/module.c Outdated Show resolved Hide resolved
@oranagra oranagra added approval-needed Waiting for core team approval to be merged state:major-decision Requires core team consensus labels Oct 26, 2022
src/module.c Outdated Show resolved Hide resolved
Copy link
Contributor

@madolson madolson left a comment

Choose a reason for hiding this comment

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

Approving the API change. Have a question about the testing but it's not necessarily something that needs to be addressed.

tests/modules/subcommands.c Outdated Show resolved Hide resolved
@oranagra
Copy link
Member

oranagra commented Nov 3, 2022

already approved in the core-team meeting (mentioned in the linked issue). merging

@oranagra oranagra merged commit 8764611 into redis:unstable Nov 3, 2022
@oranagra oranagra added release-notes indication that this issue needs to be mentioned in the release notes breaking-change This change can potentially break existing application labels Nov 3, 2022
@enjoy-binbin enjoy-binbin deleted the block_some_chars_in_module_command_name branch November 3, 2022 14:36
Mixficsol pushed a commit to Mixficsol/redis that referenced this pull request Apr 12, 2023
Today we don't place any specific restrictions on module command names.
This can cause ambiguous scenarios. For example, someone might name a
command like "module|feature" which would be incorrectly parsed by the
ACL system as a subcommand.

In this PR, we will block some chars that we know can mess things up.
Specifically ones that can appear ok at first and cause problems in some
cases (we rather surface the issue right away).

There are these characters:
 * ` ` (space) - issues with old inline protocol.
 * `\r`, `\n` (newline) - can mess up the protocol on acl error replies.
 * `|` - sub-commands.
 * `@` - ACL categories
 * `=`, `,` - info and client list fields.

note that we decided to leave `:` out as it's handled by `getSafeInfoString`
and is more likely to already been used by existing modules.
madolson pushed a commit to madolson/redis that referenced this pull request Apr 19, 2023
Today we don't place any specific restrictions on module command names.
This can cause ambiguous scenarios. For example, someone might name a
command like "module|feature" which would be incorrectly parsed by the
ACL system as a subcommand.

In this PR, we will block some chars that we know can mess things up.
Specifically ones that can appear ok at first and cause problems in some
cases (we rather surface the issue right away).

There are these characters:
 * ` ` (space) - issues with old inline protocol.
 * `\r`, `\n` (newline) - can mess up the protocol on acl error replies.
 * `|` - sub-commands.
 * `@` - ACL categories
 * `=`, `,` - info and client list fields.

note that we decided to leave `:` out as it's handled by `getSafeInfoString`
and is more likely to already been used by existing modules.
enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
Today we don't place any specific restrictions on module command names.
This can cause ambiguous scenarios. For example, someone might name a
command like "module|feature" which would be incorrectly parsed by the
ACL system as a subcommand.

In this PR, we will block some chars that we know can mess things up.
Specifically ones that can appear ok at first and cause problems in some
cases (we rather surface the issue right away).

There are these characters:
 * ` ` (space) - issues with old inline protocol.
 * `\r`, `\n` (newline) - can mess up the protocol on acl error replies.
 * `|` - sub-commands.
 * `@` - ACL categories
 * `=`, `,` - info and client list fields.

note that we decided to leave `:` out as it's handled by `getSafeInfoString`
and is more likely to already been used by existing modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval-needed Waiting for core team approval to be merged breaking-change This change can potentially break existing application release-notes indication that this issue needs to be mentioned in the release notes state:major-decision Requires core team consensus
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Consider constraining valid module command names
5 participants