Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

fix(eventbridge): refuse aws.* sources in PutEvents per entry (#1882)

iot-rocket0473a0ff4ffa
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b4a513c..869be815 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,16 @@ Versioning follows [Semantic Versioning](https://semver.org/).
### Fixed
+- **EventBridge — `PutEvents` refuses `aws.*` sources** — an entry whose `Source` starts with `aws.` now fails with `NotAuthorizedForSourceException` in its result entry and counts in `FailedEntryCount`, while the other entries of the batch are still delivered; previously it was dispatched to rules and archives like a custom event.
+- **Bedrock AgentCore — `InvokeAgentRuntime` enforces IAM policies** — with `AUTH=true`, runtime invocations now resolve to `bedrock-agentcore:InvokeAgentRuntime` and authorize against the ARN in the request path, so a policy can allow one runtime and deny another. Previously, the action was not extracted and the request bypassed identity-policy evaluation.
+- **IAM — a negated condition operator is true when its key is absent** — the evaluator treated an absent key as a failed condition for every operator, so a `Deny` guarded by `StringNotEquals`, `StringNotLike`, `ArnNotLike`, `NotIpAddress` or another negated operator never applied to a request without that key. AWS evaluates such a condition as true and denies. The single-valued negated operators now do the same, while `ForAnyValue` and the affirmative operators still fail on an absent key. Contributed by @iot-rocket.
+- **KMS — `GenerateDataKey` returns `KeyMaterialId`** — requests without `Recipient` now include the identifier of the wrapping key material. The identifier remains stable across requests and persistence reloads, and changes when the wrapping material changes. Fixes #1853.
+- **Secrets Manager — `BatchGetSecretValue` returns only the secrets the caller may read** — under `AUTH=true` a grant on `secretsmanager:BatchGetSecretValue` alone returned every secret in the request, and `Filters` were ignored, so a filtered call returned the whole store. Each secret now needs `secretsmanager:GetSecretValue` and lands in `Errors` as `AccessDeniedException` without it, a call by `Filters` also needs `secretsmanager:ListSecrets`, and the filters select the secrets as in `ListSecrets`. Contributed by @iot-rocket.
+- **CloudFormation — change set members follow the action** — `Add` and `Remove` changes carried `Replacement: False`, a `Remove` had no physical id, `PolicyAction` was never sent and a `Metadata` or policy detail had no `RequiresRecreation`. `Remove` and `Modify` now name the physical resource, a `Remove` answers `PolicyAction: Delete` and a replacing `Modify` `ReplaceAndDelete` unless the resource retains or snapshots, and attribute details answer `Never`. Contributed by @iot-rocket.
+- **CloudFormation — `AWS::SQS::Queue` applies every queue property** — `RedrivePolicy`, `RedriveAllowPolicy`, `KmsMasterKeyId`, `KmsDataKeyReusePeriodSeconds`, `SqsManagedSseEnabled`, `DeduplicationScope` and `FifoThroughputLimit` were dropped on create and update, so a dead-letter queue declared in a template never received messages, and a value SQS refuses now fails the resource instead of being stored. Contributed by @iot-rocket.
+- **Lambda — Docker executor honors timeouts above 300 seconds** — pass the configured `Timeout` to AWS RIE through `AWS_LAMBDA_FUNCTION_TIMEOUT`, preventing its default 300-second limit from ending longer invocations early. Timeout updates recycle warm containers so the RIE deadline follows the new configuration (#1844).
+- **KMS — `GenerateDataKey` returns `KeyMaterialId`** — requests without `Recipient` now include the identifier of the wrapping key material. The identifier remains stable across requests and persistence reloads, and changes when the wrapping material changes. Fixes #1853.
+- **CloudFormation — a nested stack's update deletes the resources its template drops** — a resource removed from the child template, or created by a failed child update that was rolled back, stayed in its service and in the nested stack's resource list. Contributed by @iot-rocket.
- **SQS — `QueueUrl` matches the gateway's TLS scheme (`USE_SSL=1`)** — `CreateQueue`/`GetQueueUrl`/`ListQueues` always returned `http://` URLs, and the AWS SDK v3 uses the QueueUrl itself as the request endpoint (`useQueueUrlAsEndpoint` defaults true), so a client handed that URL left the TLS-only gateway. The `AWS::SQS::Queue` CloudFormation provisioner built the same hardcoded scheme and now reuses the shared helper.
- **API Gateway v2 (HTTP API) — an unmatched route answers AWS's exact 404 body** — a request with no matching route answered `{"message": "No route found"}`; AWS answers `{"message":"Not Found"}` (compact JSON, no space after the colon). REST API (v1) is unaffected — it already answers a route miss with its own `403 MISSING_AUTHENTICATION_TOKEN` gateway response, not this literal.
- **API Gateway v2 — `apiEndpoint` follows the gateway's TLS scheme** — with `USE_SSL=1` the gateway listener serves only HTTPS, but CreateApi and the `AWS::ApiGatewayV2::Api` CloudFormation resource always returned an `http://` `apiEndpoint`, which nothing answers. They now return `https://`, or `wss://` for a WebSocket API, as AWS does. Without `USE_SSL` the endpoint keeps `http://`.
diff --git a/ministack/services/eventbridge.py b/ministack/services/eventbridge.py
index d0cba865..2b1df0e4 100644
--- a/ministack/services/eventbridge.py
+++ b/ministack/services/eventbridge.py
@@ -976,7 +976,8 @@ def _resolve_taggable_events_arn(arn):
return arn, None
-def _put_events(data):
+def _put_events(data, allow_aws_source=False):
+ """PutEvents; only built-in emitters pass ``allow_aws_source`` to publish ``aws.*`` sources."""
entries = data.get("Entries", [])
# AWS spec: PutEvents.Entries list min=1 max=10. Real AWS rejects with
# ValidationException; matching that here so SDKs see the same constraint.
@@ -997,6 +998,14 @@ def _put_events(data):
results.append({"ErrorCode": code, "ErrorMessage": message})
failed += 1
continue
+ source = entry.get("Source")
+ if not allow_aws_source and isinstance(source, str) and source.startswith("aws."):
+ results.append({
+ "ErrorCode": "NotAuthorizedForSourceException",
+ "ErrorMessage": "Not authorized for the source.",
+ })
+ failed += 1
+ continue
# AWS Time is a timestamp shape; ministack convention is int epoch seconds
# (Java SDK v2 chokes on floats). Persisted in the event_record so
# archive replay also dispatches the int form.
diff --git a/ministack/services/stepfunctions.py b/ministack/services/stepfunctions.py
index 4cb69d4b..b37a8051 100644
--- a/ministack/services/stepfunctions.py
+++ b/ministack/services/stepfunctions.py
@@ -1455,7 +1455,7 @@ def _emit_execution_status_event(execution) -> None:
"Detail": json.dumps(detail),
"Resources": [execution["executionArn"]],
}]
- })
+ }, allow_aws_source=True)
except Exception:
logger.warning("Failed to publish execution status event for %s",
execution["executionArn"], exc_info=True)
diff --git a/tests/test_eventbridge.py b/tests/test_eventbridge.py
index 80e86418..129276d3 100644
--- a/tests/test_eventbridge.py
+++ b/tests/test_eventbridge.py
@@ -1558,6 +1558,36 @@ def test_eventbridge_put_events_rejects_foreign_region_bus_arn_without_local_fal
assert msgs.get("Messages", []) == []
+def test_eventbridge_put_events_rejects_aws_source_per_entry(eb, sqs):
+ suffix = _uuid_mod.uuid4().hex[:8]
+ bus_name = f"qa-eb-aws-src-bus-{suffix}"
+ eb.create_event_bus(Name=bus_name)
+ q_url = sqs.create_queue(QueueName=f"qa-eb-aws-src-q-{suffix}")["QueueUrl"]
+ q_arn = sqs.get_queue_attributes(QueueUrl=q_url, AttributeNames=["QueueArn"])["Attributes"]["QueueArn"]
+ eb.put_rule(
+ Name="qa-eb-aws-src-rule",
+ EventBusName=bus_name,
+ EventPattern=json.dumps({"detail-type": ["probe"]}),
+ State="ENABLED",
+ )
+ eb.put_targets(Rule="qa-eb-aws-src-rule", EventBusName=bus_name, Targets=[{"Id": "t1", "Arn": q_arn}])
+
+ sources = ["myapp", "aws.s3", "aws", "AWS.s3", "aws.partner/example.com/1/x"]
+ response = eb.put_events(Entries=[
+ {"Source": s, "DetailType": "probe", "Detail": "{}", "EventBusName": bus_name} for s in sources
+ ])
+
+ assert response["FailedEntryCount"] == 2
+ denied = {"ErrorCode": "NotAuthorizedForSourceException", "ErrorMessage": "Not authorized for the source."}
+ assert [response["Entries"][i] for i in (1, 4)] == [denied, denied]
+ assert all("EventId" in response["Entries"][i] for i in (0, 2, 3))
+ delivered = []
+ for _ in range(5):
+ msgs = sqs.receive_message(QueueUrl=q_url, MaxNumberOfMessages=10, WaitTimeSeconds=1)
+ delivered += [json.loads(m["Body"])["source"] for m in msgs.get("Messages", [])]
+ assert sorted(delivered) == ["AWS.s3", "aws", "myapp"]
+
+
def test_eventbridge_cfn_rule_accessible_via_api(eb, sqs, cfn):
"""Rules created via CloudFormation should be accessible via the EventBridge API."""
bus_name = "qa-eb-cfn-bus"