Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Allow trustedCommands wildcards in the middle of command strings and within command words

Open webbd-jabil opened this issue 10 months ago • 1 comments

Feature Description

Current Limitation Currently, wildcards (*) in trustedCommands only work:

  • At the end of a command
  • Must be preceded by a space
  • Example: aws ec2 describe-dhcp-options * ✅
  • Cannot do: aws * describe* ❌

Requested Enhancement Be able to use wildcards:

  • In the middle of commands: aws * describe*
  • Within command words: describe* (without requiring a space before the *)
  • This would allow patterns like:
  • aws * describe* - All AWS describe commands
  • aws ec2 * - All AWS EC2 commands
  • git * - All git commands
  • kubectl get * - All kubectl get commands

Benefits

  1. Easier Maintenance: One pattern instead of dozens of individual commands
  2. Faster Setup: Quickly grant broad permissions with patterns
  3. More Flexible: Better control over what Kiro can do autonomously
  4. Reduced Errors: Fewer entries means less chance of typos or missing commands

Use Case

Before (Current):

{
  "trustedCommands": [
    "aws ec2 describe-instances *",
    "aws ec2 describe-vpcs *",
    "aws ec2 describe-subnets *",
    "aws ec2 describe-security-groups *",
    "aws ec2 describe-dhcp-options *",
    "aws ec2 describe-vpc-endpoints *",
    "aws iam list-roles *",
    "aws iam list-policies *",
    "aws iam get-role *"
  ]
}

After (Proposed):

{
  "trustedCommands": [
    "aws * describe* *",
    "aws * list* *",
    "aws * get* *"
  ]
}

Additional Context

The wildcard matching could work similar to glob patterns:

  • * matches any sequence of characters (including none)
  • Wildcards can appear anywhere in the pattern
  • Multiple wildcards in a single pattern are supported
  • Matching is done word-by-word or character-by-character depending on position

Pattern Matching Examples:

  • aws * describe* matches:
  • aws ec2 describe-instances
  • aws s3 describe-bucket
  • aws iam describe-role
  • git * matches:
  • git status
  • git commit -m "message"
  • git push origin main

Security Considerations

While this makes the feature more powerful, it's important to note:

  1. Broader permissions: Patterns like aws * would allow ALL AWS commands
  2. Review carefully: Users should understand what each pattern permits
  3. Start narrow: Begin with specific patterns and broaden as needed
  4. Documentation: Clear examples of safe vs. risky patterns

webbd-jabil avatar Jan 16 '26 18:01 webbd-jabil

+1

petersmythe avatar Feb 13 '26 08:02 petersmythe