Describe the bug
DLS accepts a role definition containing date math expressions (e.g., now-30d/d) without any validation error (HTTP 201). The issue only surfaces at query time when a user mapped to that role attempts a search, resulting in:
'now' is not allowed in DLS queries
The role appears correctly configured but fails at query time. Either date math should be supported in DLS filters (preferred), or the Security plugin should validate and reject at role creation time.
Related component
Other
To Reproduce
- Create a DLS role with a date math filter:
PUT _plugins/_security/api/roles/time_restricted
{
"cluster_permissions": [],
"index_permissions": [
{
"index_patterns": ["test-index-*"],
"dls": "{"range": {"@timestamp": {"gte": "now-30d/d"}}}",
"allowed_actions": ["read"]
}
]
}
Response: 201 Created — no validation error.
- Map a user to the role:
PUT _plugins/_security/api/rolesmapping/time_restricted
{
"users": ["restricted_user"]
}
- Query as the restricted user:
GET test-index-*/_search
{
"query": { "match_all": {} }
}
- Error returned:
{
"error": {
"root_cause": [{"type": "parse_exception", "reason": "could not read the current timestamp"}],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "'now' is not allowed in DLS queries"
}
},
"status": 400
}
Expected behavior
Either:
- (Preferred) Support date math expressions (now, now-30d/d, etc.) in DLS queries, resolving them at query time. This is a common access control pattern — restricting users to a rolling time window of data.
- (Minimum fix) Validate the DLS query string at role creation time and reject expressions containing
now with a clear error, rather than silently accepting them and failing later at query time.
Additional Details
Plugins
Security plugin (Fine-Grained Access Control / DLS)
Screenshots
Host/Environment (please complete the following information):
- Amazon OpenSearch Service (managed)
- Version: 2.13
Additional context
Use case: Multiple users query the same index. Some users should only see data from the last N days (rolling window), while admins retain full access. DLS with a time-range filter is the natural solution, but the lack of date math support forces workarounds like scheduled Lambda functions to rotate hardcoded epoch timestamps in the role definition.
Describe the bug
DLS accepts a role definition containing date math expressions (e.g.,
now-30d/d) without any validation error (HTTP 201). The issue only surfaces at query time when a user mapped to that role attempts a search, resulting in:'now' is not allowed in DLS queriesThe role appears correctly configured but fails at query time. Either date math should be supported in DLS filters (preferred), or the Security plugin should validate and reject at role creation time.
Related component
Other
To Reproduce
PUT _plugins/_security/api/roles/time_restricted
{
"cluster_permissions": [],
"index_permissions": [
{
"index_patterns": ["test-index-*"],
"dls": "{"range": {"@timestamp": {"gte": "now-30d/d"}}}",
"allowed_actions": ["read"]
}
]
}
Response: 201 Created — no validation error.
PUT _plugins/_security/api/rolesmapping/time_restricted
{
"users": ["restricted_user"]
}
GET test-index-*/_search
{
"query": { "match_all": {} }
}
{
"error": {
"root_cause": [{"type": "parse_exception", "reason": "could not read the current timestamp"}],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "'now' is not allowed in DLS queries"
}
},
"status": 400
}
Expected behavior
Either:
nowwith a clear error, rather than silently accepting them and failing later at query time.Additional Details
Plugins
Security plugin (Fine-Grained Access Control / DLS)
Screenshots
Host/Environment (please complete the following information):
Additional context
Use case: Multiple users query the same index. Some users should only see data from the last N days (rolling window), while admins retain full access. DLS with a time-range filter is the natural solution, but the lack of date math support forces workarounds like scheduled Lambda functions to rotate hardcoded epoch timestamps in the role definition.