GoogleCloudPlatform / guest-agent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improper parsing of /etc/passwd when username is suffix of another user

Matir opened this issue · comments

Steps to reproduce:

  1. Create a user testagent with SSH keys in project/instance metadata.
  2. Wait for agent to create user & provision.
  3. Create a user agent with SSH keys in project/instance metadata.
  4. Observe keys for user agent written into /home/testagent/.ssh/authorized_keys

This occurs because the code for getPasswd only checks that the entry in /etc/passwd contains the username followed by :. Of course, it only occurs if the longer username is first in /etc/passwd and the shorter username is 2nd in the project/instance metadata.

I'll send a PR with a fix shortly.