Open programmerq opened 8 months ago
the system should correctly parse string literals within the conditions for the filter, whether they are enclosed in single or double quotes
Our predicate language is based on Go syntax. Single quotes are not valid string literals in Go, and allowing our predicate language to diverge from Go would be a fair amount of work for little gain.
The proper fix here IMO would be to reject the request that creates or updates a role with an invalid filter, not to make this invalid filter valid.
As a side note - the same issue applies for label expressions. They aren't evaluated on create/update, so Teleport will accept a role update with an invalid label expression only to fail later on when the role is evaluated.
cc @nklaassen - maybe a good thing to clean up on a support shift in the future.
+1 for a fix to label expression input validation
Expected Behavior
When defining a
require_session_join
filter in Teleport role configurations, the system should correctly parse string literals within the conditions for the filter, whether they are enclosed in single or double quotes, without causing session join failures.Alternatively, Teleport could reject conditionals that include single quotes since they are known to cause this problem.
Current Behavior
A moderator role with a
require_session_join
filter using single quotes in the string literal throws a parsing error:illegal rune literal
. For example,contains(user.spec.roles, 'team-auditor')
will cause an auditor attempting to join a session as an observer to fail with the mentioned error.Bug Details
Teleport Version
15.1.3
Recreation Steps
require_session_join
filter using single quotes in the conditional statement.Debug Logs
On the SSH node, when the party attempts to join, the node parses any conditionals specified in the role. The following stack trace appears in the Teleport node logs, and the user is disconnected:
Example role:
Notes
It may be beneficial to include input validation when saving role in the first place. In this particular case, it might also work for it to automatically replace single quotes with double quotes. It is very common for single quotes and double quotes to be relatively interchangeable, so this is likely to trip up users in the future.