Score:0

EC2 instance connect - impersonating anyone on the server by default

in flag

I am looking at ec2 instance connect and it seems it just allows you to impersonate any user that exists on host.

How is that useful or secure? In what scenario would I want to allow this functionality?

i am testing it with IAM role that has all privileges

mssh [email protected] eu-west-2 --profile myprofile -t $INSTANCE_ID 

logs me on as myself, fine ( my user exists on host).

mssh [email protected] --region eu-west-2 --profile myprofile -t $INSTANCE_ID 

logs me on as some other user that already exists on this server.

What is the point? Looks like this behaviour is by design. And anyone with required IAM permissions for ec2-instance-connect can impersonate any user on the host.

Document below mentions how you can scope user permission so your IAM policy only allow you to login as a specific user by leveraging ‘ec2:osuser’ value https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html

Looks like by default you can impersonate anyone but can limit what user is allowed to be logged on using that value. Seems like default security is way too open.

Appleoddity avatar
ng flag
I think you’re looking at this wrong. As you said, `ec2-instance-connect` permissions are required. Meaning you must grant this permission to a user. So actually it is not insecure by default - because users do NOT have this permission by default. So, if you are going to grant the permission you should also understand how to use conditional checks to properly scope the permission. That is the same for all IAM permissions. You could, for instance, check if the `osuser` value matches the AWS username or an attribute of the user so users in AWS can only login as themselves to the instance.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.