Field notes

12 min read

How Small Application Bugs Reach Cloud Resources

Two labs from my cloud security research: a preview service bug on Alibaba Cloud and a CI injection on AWS, followed through to private storage.

I built two labs for my earlier cloud security research. One runs a URL preview service in Kubernetes on Alibaba Cloud. The other uses a Gitea Actions workflow with temporary AWS credentials.

In each lab, I started with an application bug and followed the access available to the affected process. The preview service could read a workload token and send requests to an internal broker. The workflow could run commands taken from an issue body. Both paths ended with a read from private storage.

This post walks through the steps, including where the credentials came from, which roles could be assumed, and how I found the object names needed for the final reads.

Entry pointWhat the bug allowsCloud access used afterward
Preview serviceRead local files and send internal requestsUse a workload token and an internal management broker
Repository workflowExecute extra commands inside a jobUse the pipeline’s credentials and assume connected roles

Alibaba Cloud: From the Preview Service to Private Storage

For the first lab, I set up a public URL preview API, a Kubernetes workload identity, an internal command broker, and private object storage. The preview API has two useful bugs: it accepts local file URLs, and it can fetch internal addresses.

I used the file read to get the workload token, exchanged it for temporary credentials, and called the broker through the preview service. The broker then gave me access to a pod containing the object name.

Diagram of the preview service, mounted workload token, temporary RAM credentials, internal broker, and private storage object.Diagram of the preview service, mounted workload token, temporary RAM credentials, internal broker, and private storage object.

Reading Files Through the Preview API

The API accepts HTTP, HTTPS, and local file URLs in the same input field:

https://example.com/article
file:///proc/self/environ

The second URL reads the process environment with the preview service’s file permissions. In this lab, that exposes the cloud endpoints, role information, and storage location. The process mount information also shows where the projected workload token is mounted.

The role and identity-provider references are not enough to authenticate on their own. I needed the token file as well.

The HTTP fetcher also accepts internal destinations. That gives me server-side request forgery, or SSRF, which I use later to reach the broker from the preview service’s network.

Exchanging the Workload Token

The pod uses RAM Roles for Service Accounts (RRSA). It presents a projected service-account token to Alibaba Cloud’s token service and receives temporary credentials for its assigned RAM role.

The token is stored in a file the application can read. Two relevant claims in the lab are:

{
  "aud": ["sts.aliyuncs.com"],
  "sub": "system:serviceaccount:research-a:entry"
}

Here, aud identifies the intended recipient, and sub identifies the entry service account in the research-a namespace.

With the token and the role and identity-provider references from the environment, I could call AssumeRoleWithOIDC. The token service checks the configured trust relationship before issuing credentials. The resulting session has the permissions of the assigned RAM role.

There are two different credentials to keep track of here. The projected token identifies the Kubernetes service account to the token service. The returned RAM credentials identify the role session used for later requests. Reading the token file gets me through the first step; it still leaves the broker’s authentication and pod permissions to check.

Calling the Internal Broker

I built a custom broker with a simulated management interface. It accepts the temporary credentials, lists simulated instances, and runs commands inside their backing pods. The broker uses the caller’s RAM identity and its mapped Kubernetes permissions for pod access.

To run a command, I needed all three of these:

  1. A request from the preview service to the broker’s internal address.
  2. Credentials for a RAM identity the broker accepts.
  3. Kubernetes permissions for the requested operation and target pod.

The broker is internal, so I still needed the preview service’s SSRF after obtaining credentials.

Finding the Object Name

One of the pods contains a small file with the object name. I combined that name with the storage prefix from the preview service’s environment to make the final read.

The RAM role can read the object but cannot list the protected prefix. Listing stays denied throughout the lab; the pod file supplies the name needed to request the object directly.

AWS: From an Issue to Private Release Artifacts

For the second lab, I used a repository issue as a release request. Opening the issue starts a Gitea Actions workflow, which obtains temporary AWS credentials and passes the request to a helper script.

The helper writes part of the issue body into a shell script and runs it. By adding another command to that input, I could execute it inside the job with the pipeline’s credentials.

Diagram of the Gitea pipeline injection and AWS role chain from issue body to private release artifacts.Diagram of the Gitea pipeline injection and AWS role chain from issue body to private release artifacts.

Issue Text Becomes Shell Code

The helper checks whether the release value starts with the expected prefix. It accepts the input below because the first line passes that check:

release-2026.11.1
echo "This line should have stayed issue text"

The script-generation code looks like this, with the surrounding logic removed:

{
  printf '%s\n' '#!/bin/sh'
  printf 'RELEASE_CANDIDATE=%s\n' "$candidate"
} > "$manifest"
sh "$manifest"

printf preserves the newline in $candidate, so the generated file contains a second command. sh then executes both lines.

The workflow quotes the argument when calling the helper, but the helper later writes it as shell code. That later step introduces the script injection.

The quoted argument keeps the whole issue value together while the helper runs, including the newline. The helper then copies that newline into the generated file, where it separates shell statements. There are two shell invocations to consider: the one calling the helper, and the one reading the file it creates.

For this input, the generated file contains:

#!/bin/sh
RELEASE_CANDIDATE=release-2026.11.1
echo "This line should have stayed issue text"

The prefix check has already passed before this file runs. To fix the helper, I would validate the entire release identifier and keep the value as data throughout processing. Adding quotes only at the earlier call site would still leave the generated file containing a separate command.

The job obtains AWS credentials before running the helper. My extra commands therefore run with a pipeline session already available.

Following the Role Chain

I split the AWS permissions across four roles:

RoleAccess in the lab
PipelineInspect and assume the recon role
ReconRead configuration and release records, then assume broker
BrokerRetrieve a secret version and assume artifact
ArtifactRead the release manifest and payload

The recon role can discover the secret’s name but cannot retrieve its value. The broker can retrieve the required version, while the artifact role performs the storage read. At each step, the caller needs authorization to assume the next role and must satisfy its trust conditions.

Some of these assumptions require an external ID. As the AWS documentation explains, an external ID is not a secret. In this lab, I could read the required value through the configured role chain and supply it as an already authorized caller.

Checking Which Role a Request Uses

Each AssumeRole call returns a new set of temporary credentials. The next request needs to use that set. Calling the API does not switch the credentials of an existing shell or client. The returned access key, secret key, and session token belong together, as described in the AWS guide to using temporary credentials.

For a walkthrough like this, separate profiles for the pipeline, recon, broker, and artifact sessions make the requests easier to follow. Before a secret read, the broker profile’s identity can be checked with:

aws sts get-caller-identity \
  --profile lab-broker \
  --query Arn \
  --output text

GetCallerIdentity identifies the session signing that request. Use the same profile for the identity check and the operation being tested.

In this lab, a secret read using recon credentials should be denied: recon only discovers the secret’s name. To test the version selection, the request needs the broker session. Checking the caller first helps distinguish a request made with the wrong credentials from a problem with the secret name or version stage.

Reading the Release Configuration

I stored the release information across Lambda configuration, Parameter Store, and a DynamoDB registry.

Reading the Lambda environment gives me the parameter path and registry reference. Parameter Store contains the secret name, role references, access-point endpoints, and naming formats. A query to the registry returns the published release and its generation; the role does not need permission to scan the whole table.

I only read the Lambda configuration here. The function does not need to run. Its environment contains references I need for the next requests, even though it contains no credentials.

The orchestration information and logs show processing status. For the published release record, I needed the registry.

Selecting the Matching Secret Version

The broker can retrieve a secret value, but it cannot list all versions and labels. To select the right version, I needed the label format from configuration and the publication identifier from the registry.

I deliberately left AWSCURRENT on an older generation in the lab data:

SourceGenerationMeaning
Published registry record43The release being processed
Default secret version42Material from the older release
Release-specific version43Material matching the published record

Without a version selector, GetSecretValue returns the version labeled AWSCURRENT. In this setup, that means a successful read returns generation 42, while the registry says the published release is generation 43.

The lab uses pub-<publication-id> for its version labels. With the broker session configured as a profile, I can request the matching version explicitly:

aws secretsmanager get-secret-value \
  --secret-id "$BROKER_SECRET" \
  --version-stage "pub-$PUBLICATION_ID" \
  --profile lab-broker

BROKER_SECRET comes from Parameter Store, and PUBLICATION_ID comes from the published registry record. The matching secret version contains the context needed to assume the artifact role. The older value fails the condition configured for that assumption.

This check makes the caller select the right release, but the job can read everything needed to do that. After gaining command execution, I could make the same reads as the release workflow and obtain the matching value.

For example, a broker read without a version selector returns generation 42. The request is allowed, but that value cannot satisfy the artifact assumption for the published generation 43. Repeating the read with the default selector keeps returning the older material.

To check this step, compare the publication identifier in the registry, the stage sent to Secrets Manager, and the generation in the returned value. Those should agree before testing the artifact role assumption. A denied assumption and a secret read that selected an older release need different fixes.

Reading the Manifest and Payload

With the artifact role, I read a manifest through one S3 access point and the payload through another. Both endpoints come from configuration. The naming format and published release record give me the manifest path; the manifest then supplies the payload name.

As in the Alibaba Cloud lab, I never needed to list the storage. I already had the exact object names. The payload is KMS-encrypted, and the artifact role has the permissions needed to download it.

What I Would Check in a Similar Setup

For the preview service, I would start with the allowed URL schemes and destinations, then check why it has access to a workload token and a management broker. For the workflow, I would fix the generated-script handling and review which credentials the job receives before processing issue input.

These are the checks I would carry over from the labs:

  1. Restrict the fetcher. Check URL schemes, resolved addresses, and redirect destinations.
  2. Reduce the preview service’s access. Give its workload identity only the permissions the preview feature needs, and restrict its access to internal management services.
  3. Validate the whole release value. A valid prefix is not enough. Keep issue text out of generated shell code.
  4. Separate input handling from privileged release work. Check whether the job needs cloud credentials before it has validated the request.
  5. Follow every permitted role assumption. Include the configuration and secret reads that supply the values required by the next role.
  6. Check job output after each assumption. In the AWS lab, the initial credentials are masked, but credentials returned by later role assumptions are not automatically masked.

Temporary credentials still expire, but a readable workload token or a controlled pipeline can provide another session while the application bug remains available.

Checks I Added to the Labs

Alongside the working paths, I included checks for rejected credentials, unrelated command targets, and storage reads outside the assigned scope. I wanted to verify where each role’s access stopped as well as where it worked.

For the Alibaba Cloud lab, these checks cover three separate requests:

RequestAllowed caseRejected case
Broker authenticationCredentials for the assigned workload identityCredentials the broker does not accept
Pod commandAn operation against the assigned targetAn unrelated command target
Storage readThe object within the role’s assigned scopeAn object outside that scope

The order matters when checking a failure. A request that cannot reach the broker has not tested the identity mapping. Credentials rejected by the broker have not tested permission to run a command in a pod. For a target-permission check, keep the network path and accepted identity the same, then change the requested target.

I would record the active identity, destination, requested resource, and response for each check. That gives enough information to compare a working request with a rejected one without putting token values or temporary credentials in the notes.

I also checked the release data: role references must point to the expected roles, the publication identifier must select the intended secret version, and the manifest must match that release. Otherwise, a failed read could come from stale lab data rather than a policy doing its job.