Skip to content

SSM SendCommand is accepted, but Windows command invocation fails with AccessDenied, ResponseCode -1, and no output

0

Update — Resolved (October 10, 2026)

The issue has been resolved. The cause was insufficient IAM permissions. After correcting the IAM permissions, SSM Run Command worked successfully.

Thank you to everyone who provided suggestions. The original investigation below is retained for reference and describes the situation before the fix.


I am investigating an AWS Systems Manager Run Command authorization failure on a Windows EC2 instance.

The SendCommand API call succeeds and returns a CommandId, but the subsequent command invocation fails with AccessDenied. I would like to understand which authorization check can fail after the command has been accepted, and how to obtain evidence identifying the denied principal, action, resource, and policy.

Environment

  • Target: Windows Server 2022 EC2 instance
  • SSM Agent version reported by Systems Manager: 3.3.5226.0
  • The instance was reported as Online by Systems Manager.
  • Document: AWS-RunPowerShellScript, version 1
  • Plugin: aws:runPowerShellScript
  • The command uses inline PowerShell rather than downloading a script or package from S3.
  • No S3 output destination or CloudWatch output logging was configured for these commands.

Observed behavior

  1. SendCommand succeeds and returns a CommandId.

  2. The corresponding CloudTrail SendCommand event has no errorCode or errorMessage and records the command as Pending.

  3. When we retrieve the invocation details, both the invocation and plugin report:

    Status: Failed StatusDetails: AccessDenied ResponseCode: -1 Output: empty

  4. We have not obtained a detailed authorization error identifying the denied principal, action, resource, or policy.

Comparison already performed

On October 5, 2026, we sent the same command to the same target instance using two caller identities:

  • Direct IAM user credentials
  • Temporary credentials for a dedicated assumed role

Both SendCommand calls were accepted, and both command invocations subsequently failed with the same AccessDenied / ResponseCode -1 result.

The request timestamps were approximately:

  • IAM user: 2026-10-05 13:36:40 UTC
  • Assumed role: 2026-10-05 13:36:44 UTC

Important limitations

  • We have not recovered the SSM Agent logs from this particular failed instance.
  • Therefore, we cannot confirm from local logs whether the Agent received either command or attempted to launch PowerShell.
  • The Online status is not being treated as proof that Run Command delivery or authorization succeeded.
  • We are not claiming that all IAM, SCP, permissions boundary, session policy, or endpoint policy causes have been ruled out.
  • We are not assuming this is an AWS service defect.

Documentation reviewed

The Run Command status documentation describes invocation-level AccessDenied as the initiating IAM user or role lacking access to the targeted managed node.

The Run Command setup documentation also states that global condition keys used with SendCommand require consideration of aws:ViaAWSService=true. It describes tag-condition mismatches producing AccessDenied in execution results.

Questions

  1. Which authorization checks can produce invocation-level AccessDenied after SendCommand has successfully returned a CommandId?

  2. Does the combination of AccessDenied, ResponseCode -1, and empty output distinguish a service-side target authorization failure from an Agent-side failure? Or is additional evidence required?

  3. Where can the actual denied principal, action, resource, and policy be observed when the original CloudTrail SendCommand event contains no error?

  4. Can conditions involving resource tags, aws:SourceIp, aws:SourceVpc, aws:SourceVpce, or aws:ViaAWSService allow the initial request but reject a subsequent authorization step? What evidence would confirm this?

  5. Could such a failure occur before the command reaches the Agent, leaving no corresponding command entry in the Agent logs?

  6. What is the smallest useful diagnostic procedure for this situation? I would prefer evidence-based checks rather than adding broad administrative permissions or repeatedly creating replacement instances.

If anyone has encountered this specific pattern, a reference to the relevant authorization behavior or a resolved case would be very helpful.

  • A later single-node test reproduced the same AccessDenied / ResponseCode -1 within the policy's finite allowed time window, even with a separate exact-document/exact-node Allow for ViaAWSService=true without network, tag, or RequestedRegion conditions in that statement. Native SSM Agent core/worker logs were collected independently of Run Command and continued after the request, but the collected records did not contain the CommandId; this does not prove non-delivery or complete log coverage. The invocation's TraceOutput was absent and the console showed empty output/error. The IAM Access Troubleshooter preview currently documents IAM API support and excludes requests made by a service on our behalf. Is there a supported SSM-specific way to retrieve the per-target denial evaluation, or a discriminating observation that identifies the actual denied action/resource/context before another test?

3 Answers
0

Two phases are at work here, and the distinction answers most of your questions at once.

Q1: What can deny after SendCommand returns

ssm:SendCommand accepts two resource types — the document ARN and the instance ARN. The API-level check and the per-target check are evaluated separately, which is why status is tracked per invocation rather than per command. A command can be accepted and then fail authorization against a specific target.

Candidates for the second check:

  • Instance ARN not covered by the policy's resource list, even though the document is
  • ssm:resourceTag/* conditions not matching the instance's actual tags — the Run Command docs explicitly call this out as producing AccessDenied in execution results
  • SCP or permissions boundary evaluated against the target resource
  • Network conditions, which is the interesting one

Q4: Yes, and this is where I'd look first

Your citation of aws:ViaAWSService=true in the Run Command setup docs is the thread worth pulling.

The per-target authorization is performed by SSM on your behalf using a forward access session. IAM is explicit about what that means for network keys:

Unlike with aws:SourceIp, you must use aws:ViaAWSService or aws:CalledVia to allow FAS requests, because the source VPC of the initial request is not preserved.

And the same applies to aws:SourceVpce.

So:

KeyPreserved in FAS?Can allow-then-deny
aws:SourceIpYes, when the initial request hit a public endpointUnlikely
aws:SourceVpcNoYes
aws:SourceVpceNoYes

If any policy in the evaluation chain restricts on aws:SourceVpc or aws:SourceVpce without a ViaAWSService or CalledVia exception, your direct call passes and the FAS call fails. That reproduces your symptom precisely.

Your two-identity comparison strengthens this. Both an IAM user and an assumed role failing identically, four seconds apart, points at something shared rather than something principal-specific — a policy condition on the network path, or an SCP covering the account. If you called through a VPC endpoint for SSM, this becomes my leading hypothesis.

Note one subtlety: if the initial request went to a public SSM endpoint, subsequent FAS requests carry the same aws:SourceIp value. So a SourceIp restriction is less likely to be the cause than a VPC-based one.

Q2: The combination is strong evidence, not proof

ResponseCode: -1 with empty output means no process produced an exit code. Had the Agent launched PowerShell and failed, you'd see a real exit code and usually some output. AccessDenied is a service-assigned status detail, not something the Agent generates for a failed launch.

Taken together that points firmly at service-side target authorization. But you're right not to treat it as conclusive — Agent logs are what close it, and you've correctly flagged that you don't have them.

Q5: Yes, definitively

If the per-target authorization fails, the command is never dispatched. There will be no corresponding entry in AmazonSSMAgent.log or the plugin logs. Absence of an Agent-side record is consistent with your hypothesis rather than evidence against it — and ResponseCode: -1 corroborates that nothing executed.

Q3 and Q6: The diagnostic procedure

There is no CloudTrail event for the per-target check, which is why the SendCommand event is clean. Policy simulation is the substitute, and it's the smallest useful test:

aws iam simulate-principal-policy \
  --policy-source-arn arn:aws:iam::ACCOUNT:role/YOUR_ROLE \
  --action-names ssm:SendCommand \
  --resource-arns \
      arn:aws:ec2:REGION:ACCOUNT:instance/i-x \
      arn:aws:ssm:REGION::document/AWS-RunPowerShellScript \
  --context-entries \
      ContextKeyName=aws:ViaAWSService,ContextKeyType=boolean,ContextKeyValues=true

Run it twice — once with ViaAWSService=true, once with false. If it allows on false and denies on true, you have your answer, and the output names the deciding statement. That's the evidence you're asking for in Q3, and it costs nothing.

Add aws:SourceVpc and aws:SourceVpce context entries to the true run to model the FAS call accurately.

Then, in order of cost:

  1. Grep every policy in the chain — identity, boundary, SCP, VPC endpoint policy — for SourceVpc, SourceVpce, SourceIp, and ssm:resourceTag. Any of these without a ViaAWSService or CalledVia exception is a candidate.
  2. Compare the instance's actual tags against any ssm:resourceTag conditions. A single missing or misspelled tag produces exactly this.
  3. Check the SSM VPC endpoint policy if you have one — it's easy to overlook and applies to both principals.

The remedy, if it's FAS

The standard shape, from AWS's own guidance on this class of problem:

{
  "Effect": "Deny",
  "Action": "*",
  "Resource": "*",
  "Condition": {
    "NotIpAddress": { "aws:SourceIp": ["203.0.113.0/24"] },
    "Bool": { "aws:ViaAWSService": "false" }
  }
}

The ViaAWSService: false clause exempts service-initiated calls from the restriction. For VPC-based conditions substitute accordingly, and prefer aws:CalledVia scoped to ssm.amazonaws.com over a blanket ViaAWSService if you want to keep the restriction tight.


If the simulation comes back allowing under both conditions, the hypothesis is wrong and the next place to look is tag conditions against the instance's real tags. Either way you'll know within a few minutes, without broadening permissions or rebuilding anything.

EXPERT

answered a month ago

  • Thank you. The preserved sender policy already had a separate Allow for the exact document and node with ViaAWSService=true, without a RequestedRegion, SourceVpc, SourceVpce, or tag condition. Both Allow statements had a time limit, and the failure was reported well before that limit. We understand that policy simulation cannot recover the actual context of the failed request. Is there a documented way to obtain the per-target authorization evidence after SendCommand acceptance, or a supported reference explaining whether that check traverses the customer-owned SSM VPC endpoint? The historical node is already terminated and its Agent logs were not recovered. We would like to identify a discriminating observation before launching another test, rather than broaden permissions or repeat the same comparison.

0

Since both the IAM user and the assumed role fail the same way, I'd look for a policy that applies to both identities, for example an SCP, permissions boundary, or common policy conditions.

One thing I'd check closely is any Deny using aws:SourceIp, aws:SourceVpc, or aws:SourceVpce. AWS specifically calls out that network-based condition keys can affect requests made by AWS services on your behalf, which is where aws:ViaAWSService becomes important. If that's the cause, you'd typically see a source condition without an "aws:ViaAWSService": "false" exclusion.

I'd check the identity policies, permissions boundaries and SCPs for those conditions, as well as any ssm:resourceTag conditions. Then search CloudTrail around 13:36:40 UTC for AccessDenied events rather than looking only at the successful SendCommand call.

The other useful piece of evidence would be the SSM Agent log. Search C:\ProgramData\Amazon\SSM\Logs\amazon-ssm-agent.log for the CommandId. If it never appears, that would help narrow this toward something happening before agent/plugin execution. If it does appear, the surrounding log entries should show how far the command got.

I wouldn't add broad permissions yet. Given that two different callers produce the same result, comparing the policies and conditions that apply to both is probably a better next step.

answered a month ago

EXPERT

reviewed 11 days ago

0

The most likely cause of this pattern is a plain missing permission for the caller on the target, and the OP's update fits that. The documented meaning of invocation-level AccessDenied is that the initiating user or role lacks access to the targeted managed node. Check that first, before any exotic network-condition theory.

Some points in the first answer are stated more firmly than the documentation supports:

  • The docs don't describe a separate per-target forward-access-session check, or say that no CloudTrail event exists for it.
  • "Definitively" never reaching the Agent is an inference. The docs don't state it.
  • The aws:SourceVpc/aws:SourceVpce explanation is a reasonable hypothesis, but nothing in the question points to it over a simple permission gap.

What is documented is that tag conditions (ssm:resourceTag/*) can show up as AccessDenied in execution results. That makes the cheapest check:

  1. Confirm the caller's policy allows ssm:SendCommand on both the document ARN and the instance ARN (arn:aws:ec2:REGION:ACCOUNT:instance/i-...). A policy that only lists the document is a common gap.
  2. Compare the instance's real tags against any ssm:resourceTag conditions.
  3. Run iam simulate-principal-policy for ssm:SendCommand against both ARNs. Keep in mind it only models the policies you give it and the context keys you set.

If all three pass, then look at SCPs, boundaries and ViaAWSService conditions.

EXPERT

answered 5 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.