From Curiosity to Backdoor: How I Found a Stealthy Persistence Technique in EC2 Instance Connect
The Beginning: A Simple Question
The Investigation: Following the SSH Authentication Chain
First Discovery: It's Not Magic, It's Scripts
cat /etc/ssh/sshd_config | grep -i authorized
Second Discovery: The Script Trinity


The Revelation: SSH Daemon Trusts Script Output Completely
The Experiment: From Theory to Backdoor
Step 1: Generate My Test Key
Step 2: Understand the Script Flow
Step 3: Deploy and Test

The "Oh Sh*t" Moment: It Works for ROOT Too

The Stealth Test: What Would Defenders See?
Check 1: Is it in authorized_keys?

Check 2: What about CloudTrail?
Check 3: Standard SOC Playbook
The Implications: Why This Matters
What Makes This Technique Powerful
Detection Challenges
The Detection: How to Find This Backdoor
Quick Detection Script
Lessons Learned: The Bigger Picture
1. Trust Boundaries Are Attack Surfaces
2. Legitimate Features Can Become Backdoors
3. Cloud Security Requires Host-Level Monitoring
4. Standard Playbooks Need Updates
Disclosure and Recommendations
For AWS
For Defenders
For Red Teams
Technical Details
Conclusion: Curiosity Leads to Better Security
AWS Statement
PreviousPresence-Aware Infrastructure: My Lab Knows When I'm Home (and Saves Me $$$)NextFrom Shadow IT to AI-Governed Infrastructure
Last updated