get2knowio / get2knowio/remo

Harden Python heredocs against shell injection

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
tech-debt
Dominant language
Python
Stars
2
Forks
0
Avg merge
15h 59m
Merged PRs (30d)
9

Description

## Description

Several AWS functions use unquoted heredocs (`<< EOF`) to pass Python code to `python3`. This allows shell variable expansion (`${variable}`) inside the Python code, which means user-controlled values (instance names, regions) are interpolated directly into Python source.

While input validation has been added (via `validate_name()` and `validate_region()`), the underlying pattern is still fragile. A defense-in-depth approach would pass values via environment variables instead.

## Current pattern

```bash
python3 << EOF
region = '${region}'
instance_id = '${instance_id}'
...
EOF
```

## Recommended pattern

```bash
REGION="$region" INSTANCE_ID="$instance_id" python3 << 'EOF'
import os
region = os.environ['REGION']
instance_id = os.environ['INSTANCE_ID']
...
EOF
```

## Affected functions

- `aws_create` — instance creation Python block
- `aws_destroy` — instance termination Python block
- `aws_info` — instance info Python block
- `aws_stop` — instance stop Python block
- `aws_start` — instance start Python block
- `aws_update` — instance update Python block
- `aws_update_ip` — IP update Python block
- `aws_sync` — instance discovery Python block
- `select_ssm_instance_profile` — SSM profile selection

## Priority

Low — mitigated by input validation added in recent commit.

Contributor guide

Open the contributing guide

Research direction

Locate the Python heredoc blocks in the named functions: aws_create, aws_destroy, aws_info, aws_stop, aws_start, aws_update, aws_update_ip, aws_sync, and select_ssm_instance_profile. Compare each block with the recommended quoted-heredoc and environment-variable pattern, then verify that all listed user-controlled values are passed without shell expansion. Done means every affected block uses the hardened pattern while preserving its existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, bash, python
Domain
cloud, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.