Every device connected to AWS IoT Core is a non-human identity, and the security of the fleet rests on how its certificates, IoT policies, IAM roles and provisioning flows are designed and governed. This guide walks through the controls that matter most for AWS IoT Core and AWS IoT Greengrass V2: one identity per device, policy variables that bind each device to its own resources, the credentials provider that replaces stored access keys, fleet provisioning by claim and by trusted user, Device Defender audits and the hardening practices AWS recommends for Greengrass core devices.
The audience is cloud, platform and IoT engineers who run device fleets on AWS, and the identity teams who need those fleets inside their non-human identity inventory. For the wider design of the device management platform itself, see Securing the IoT device management platform itself, which this page does not repeat.
This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.
Key takeaways
- AWS recommends a single identity per device: an X.509 client certificate for each device, and Amazon Cognito Identity for web and mobile apps.
- Use thing policy variables such as
${iot:Connection.Thing.ThingName}so one IoT policy can serve the whole fleet while each device can only connect, publish and subscribe as itself. - Devices should never hold long-lived AWS access keys. The AWS IoT credentials provider exchanges the device certificate for temporary credentials through a role alias, with a duration between 15 minutes and 12 hours.
- Fleet provisioning claim certificates are shared secrets in practice. Scope them to the provisioning topics only, protect their private keys and deactivate them at the first sign of misuse.
- Run Device Defender audits continuously. The overly permissive IoT policy check is rated Critical because one compromised certificate with a wildcard policy can affect the whole account.
- On Greengrass core devices, run components as unprivileged users, keep credentials out of component code and logs, and limit wildcards in both IAM and IoT policies.
Why AWS IoT devices are non-human identities
An IoT device that authenticates to AWS IoT Core with a certificate, publishes telemetry to MQTT topics and calls other AWS services through an IAM role is a machine identity in every sense. It has a credential, a set of permissions, an owner (or should have) and a lifecycle that runs from manufacture to decommissioning. Fleets often number in the tens or hundreds of thousands, which makes them one of the largest non-human identity populations in many AWS estates.
Three identity layers sit on top of each other in a typical deployment:
- The device certificate. An X.509 client certificate and private key used for TLS mutual authentication to the AWS IoT Core data plane.
- The AWS IoT policy. A JSON policy attached to the certificate (or thing group) that authorises data plane actions such as
iot:Connect,iot:Publish,iot:Subscribeandiot:Receive, plus shadow and job actions. - The IAM role behind a role alias. When the device needs to call other AWS services, the credentials provider issues temporary credentials for an IAM role, governed by IAM policies rather than IoT policies.
Each layer can be over-permissioned independently, and a weakness in any one of them turns a single stolen device into a foothold across the fleet. MITRE ATT&CK describes the relevant techniques: credentials stored in files on a device (T1552.001 Credentials In Files) and abuse of valid cloud credentials (T1078.004 Cloud Accounts). For the general model of device identity across vendors, see the Identity for IoT Fleets Guide.
One identity per device and unique client IDs
AWS's security best practices state that devices should use X.509 client certificates and that web and mobile applications should use Amazon Cognito Identity. Each identity should connect with a known client ID and publish and subscribe to an identified and fixed set of topics. That is the principle of least privilege applied at the protocol level.
Client IDs matter more than many teams expect. AWS IoT Core requires client IDs to be unique within each AWS account and Region. If a new connection presents a client ID that is already in use, the broker drops the existing connection. A device with an over-broad connect permission can therefore knock other devices offline simply by reusing their client IDs, whether through a firmware bug or deliberate abuse.
The fix is to require the thing name as the client ID in the IoT policy:
- Allow
iot:Connectonly onarn:aws:iot:<region>:<account>:client/${iot:Connection.Thing.ThingName}. - Attach each certificate to exactly one thing with the
AttachThingPrincipalAPI, so that the thing policy variables resolve to that device. - Monitor AWS IoT logs in CloudWatch Logs for disconnects with
"reason": "DUPLICATE_CLIENT_ID". AWS documents the filter pattern{$.reason= "DUPLICATE_CLIENT_ID" }for building metric filters and alarms.
Shared certificates across many devices are the most common anti-pattern. They make revocation all or nothing, break per-device attribution in logs and make client ID uniqueness impossible to enforce. If a manufacturing process cannot yet inject a unique certificate per device, fleet provisioning (covered below) is the supported way to exchange a shared bootstrap credential for a unique one at first connection. The trade-offs between certificates and shared keys are covered in IoT Device Certificates vs Pre-Shared Keys.
Writing least-privilege AWS IoT policies with policy variables
Writing a separate policy per device does not scale, and writing one broad policy for all devices is dangerous. Thing policy variables resolve this. Variables such as iot:Connection.Thing.ThingName, based on thing names, types and attributes, work with TLS mutual authentication or authenticated Cognito identities, so one policy document can bind every device to its own client ID, topics, shadows and jobs.
The Device Defender documentation gives clear compliant and noncompliant patterns:
| Action | Noncompliant resource | Scoped resource |
|---|---|---|
iot:Connect | client/* | client/${iot:Connection.Thing.ThingName} |
iot:Publish | topic/$aws/things/* | topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/* |
iot:Subscribe | topicfilter/$aws/things/* or topicfilter/$aws/things/+/shadow/update | topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/* and .../jobs/* |
| Shadow and job APIs | thing/* | Named things only |
The shadow and job actions covered by that check include iot:GetThingShadow, iot:UpdateThingShadow, iot:DeleteThingShadow, iotjobsdata:DescribeJobExecution, iotjobsdata:GetPendingJobExecutions, iotjobsdata:StartNextPendingJobExecution and iotjobsdata:UpdateJobExecution. iot:Receive is considered compliant when it is scoped to the topics the device is allowed to subscribe to.
Practical design rules from NHI Mgmt Group, building on AWS's guidance:
- Design the topic namespace around the thing name from the start (for example
fleet/<thing-name>/telemetry), so that policy variables can scope it. Retrofitting a flat namespace is painful. - Separate device policies from application and backend policies. A mobile app that needs to subscribe to a handful of devices should not share a policy with the devices themselves.
- Treat
*in any IoT policy resource as a review item that needs a written justification. - Version policies and roll forward carefully, because one policy change can disconnect an entire fleet.
This maps to NIST SP 800-53 AC-6 Least Privilege and IA-3 Device Identification and Authentication.
Replacing stored AWS keys with the credentials provider
Devices often need to reach services beyond the MQTT broker, such as uploading files to Amazon S3. The insecure way is to bake an IAM access key ID and secret access key into firmware. The AWS IoT Core credentials provider removes that need: the device uses its X.509 certificate to obtain temporary AWS credentials and signs requests with Signature Version 4.
The setup has four parts:
- An IAM role whose trust policy allows the service principal
credentials.iot.amazonaws.comto callsts:AssumeRole, with access policies for only the services the device needs. iam:GetRoleandiam:PassRolegranted to the administrator who creates the role alias, scoped to that role ARN.- A role alias created with
CreateRoleAlias. Devices reference the alias rather than the role ARN, so the underlying role can be changed without touching devices.credentialDurationSecondsaccepts 900 to 43,200 seconds (15 minutes to 12 hours), defaults to 3,600 seconds and must not exceed the role's maximum session duration. - An IoT policy on the device certificate allowing
iot:AssumeRoleWithCertificateon that specific role alias ARN.
The device calls the account's credentials endpoint (found with aws iot describe-endpoint --endpoint-type iot:CredentialProvider) over mutual TLS at /role-aliases/<alias>/credentials, sending the x-amzn-iot-thingname header. If that header does not match the thing attached to the certificate, the request returns 403.
The most important control here is scoping the IAM role per device. AWS provides IAM policy variables for this, usable in IAM policies only, not in IoT policies:
credentials-iot:ThingName, from thex-amzn-iot-thingnameheader.credentials-iot:ThingTypeName, added when the device provides a thing name.credentials-iot:AwsCertificateId, always provided.
A resource such as arn:aws:s3:::telemetry-bucket/${credentials-iot:ThingName}/* limits each device to its own prefix. Without it, every device in the fleet can read or overwrite every other device's objects through a shared role. NHI Mgmt Group recommends keeping the credential duration at the lowest value the device's connectivity pattern allows, and alerting on role alias changes, because altering the role behind an alias silently changes the permissions of every device using it.
Fleet provisioning by claim and by trusted user
Fleet provisioning lets AWS IoT generate and deliver device certificates and private keys the first time a device connects, with certificates signed by the Amazon Root CA. It is the main answer to the question of how to give every device a unique identity when the factory cannot. Two models are documented.
Provisioning by claim
Devices ship with a provisioning claim certificate and private key. On first connection the device uses the claim certificate to obtain a permanent certificate through either CreateKeysAndCertificate (AWS generates the key) or CreateCertificateFromCsr (the private key never leaves the device), then calls RegisterThing to create the resources defined in the provisioning template, and reconnects with the permanent certificate.
The claim certificate is a powerful shared credential. AWS's example policy restricts it to iot:Connect plus publish, receive and subscribe on $aws/certificates/create/* and $aws/provisioning-templates/<templateName>/provision/*. AWS's own guidance is explicit: protect claim private keys at all times, monitor CloudWatch metrics and logs for misuse, and deactivate the claim certificate if misuse is detected. NHI Mgmt Group recommends one claim certificate per production batch or factory line, so a leak can be contained by deactivating one batch rather than the whole product line.
Provisioning by trusted user
Here an installer or end user signs in to a mobile app or web service, which assumes an IAM role allowed to call iot:CreateProvisioningClaim on the template ARN. The app receives a temporary claim certificate and passes it to the device. The temporary claim certificate is valid for five minutes, and the device must request its permanent certificate within that window. You are responsible for authenticating and authorising the trusted users, so this model is only as strong as your app's sign-in.
Templates, roles and pre-provisioning hooks
- The template is assumed through a provisioning role that trusts the AWS IoT service principal and carries the
AWSIoTThingsRegistrationmanaged policy. Treat this role as privileged: it can create things, certificates and policies. - Template
ResourcesdefineAWS::IoT::Thing,AWS::IoT::CertificateandAWS::IoT::Policy. Attach the scoped, variable-based policy described above, never a broad one. - A pre-provisioning hook is a Lambda function that AWS IoT invokes before provisioning and that returns
allowProvisioningandparameterOverrides. Use it to check serial numbers against an allow list of manufactured devices. When grantinglambda:InvokeFunctiontoiot.amazonaws.com, include source ARN or source account conditions to prevent confused deputy attacks. - The
certificateOwnershipTokenreturned when the device obtains its certificate is valid for one hour. An unactivated, unattached certificate is deleted when the token expires.
AWS also lists just-in-time provisioning (JITP) with a provisioning template as a best practice, so devices are provisioned automatically on first connection rather than created by hand. Whichever model you use, the wider onboarding process is covered in the IoT Device Onboarding Guide.
Auditing the fleet with AWS IoT Device Defender
AWS recommends AWS IoT Device Defender to find overly permissive IoT and IAM policies and to detect multiple devices sharing one client ID. The most important audit check for identity teams is AWS IoT policies overly permissive (IOT_POLICY_OVERLY_PERMISSIVE_CHECK), rated Critical, with reason code ALLOWS_BROAD_ACCESS_TO_IOT_DATA_PLANE_ACTIONS. It fires when a policy lets a principal send or receive MQTT messages, or read or modify shadow and job execution data, for many devices. AWS notes that a compromised certificate, Cognito identity or thing group with such a policy could let an attacker read or modify shadows and jobs for all devices, connect malicious devices or launch a DDoS attack.
The documented remediation sequence is safe to operationalise:
- Create a compliant policy version with
CreatePolicyVersionandsetAsDefaultset to true. - Use
ListTargetsForPolicyto find the certificates and thing groups affected. - Confirm devices still connect; if not, roll back with
SetPolicyVersion, revise and retry.
Mitigation actions such as REPLACE_DEFAULT_POLICY_VERSION and PUBLISH_FINDINGS_TO_SNS can automate the response. Device Defender also offers related checks for overly permissive authenticated Cognito roles and potentially misconfigured IoT policies, which are worth enabling alongside it. Feed findings into the same queue as other non-human identity findings, so device policies are reviewed with the same rigour as IAM roles.
Hardening AWS IoT Greengrass V2 core devices
Greengrass core devices run components at the edge and act on behalf of the fleet in the cloud, so they deserve stronger controls than ordinary leaf devices. AWS's Greengrass V2 security best practices cover five areas.
- Grant minimum possible permissions. Run components as unprivileged users, not root, unless absolutely necessary. AWS supports running the Greengrass core software itself as a non-root user. Limit the
*wildcard forActionandResourcein IAM policies, and apply the same least-privilege principle to the AWS IoT policies attached to the core device. - Do not hardcode credentials in components. Define permissions for specific actions and resources in the Greengrass core device service role. Store any other credentials with the secret manager component, and use the AWS SDK's default credential provider chain in code.
- Do not log sensitive information. Keep secrets and personal data out of MQTT topic paths, registry thing names, types and attributes, component and Lambda logs, and the names and IDs of core devices, components, deployments and loggers. AWS stresses this applies even though local logs need root access and CloudWatch Logs need IAM permissions.
- Keep the device clock in sync. X.509 certificates expire and the clock is used to validate server certificates.
- Review cipher suites. Greengrass selects the latest TLS cipher suites available by default; consider disabling legacy suites such as CBC suites.
Because the core device service role is shared by every component on the device, it is the Greengrass equivalent of an over-privileged service account. NHI Mgmt Group recommends giving each core device group its own service role scoped to the resources that group uses, rather than one account-wide role, and reviewing it whenever a new component is deployed. The Greengrass security documentation also covers FIPS endpoints, interface VPC endpoints (AWS PrivateLink), code integrity and proxy configuration, which are worth reviewing for regulated deployments.
Clocks, server validation and resilience
Two connection hygiene points from AWS's guidance prevent outages that teams often misdiagnose as identity failures:
- Clock sync. A factory time setting is not sufficient because real-time clocks drift and batteries discharge. Include an NTP client and wait for synchronisation before connecting to AWS IoT Core. If NTP is not possible, let a user set the time.
- Server certificate validation. Devices must verify that the server presents a certificate for
iot.amazonaws.comfrom a trusted certificate authority. AWS uses limited validity periods and rotates server certificates before expiry, so pin the CA trust store, not individual leaf certificates.
AWS also suggests keeping a copy of data in a second Region. Note that the Disaster Recovery for AWS IoT solution is no longer available; AWS deprecated its GitHub library in July 2023. Plan any multi-Region identity design (certificates registered in both Regions, policies kept in sync) yourself.
Common failure patterns
- One certificate for the whole product line. Revocation becomes impossible without bricking every device, and client ID conflicts follow.
- Wildcard IoT policies left from prototyping.
client/*andtopic/$aws/things/*survive into production and trip the Critical Device Defender check. - IAM access keys in firmware. Long-lived keys extracted from one device give an attacker durable cloud access; the credentials provider exists to prevent this.
- A shared credentials provider role without per-thing scoping. Every device can reach every other device's S3 prefix or table rows.
- Claim certificates treated as low risk. A leaked claim key lets anyone mint new device identities until it is deactivated.
- Greengrass components running as root with a broad service role. One vulnerable component inherits the whole device's cloud permissions.
- No owner for device identities. Certificates for decommissioned devices remain active indefinitely.
Practitioner checklist
- Issue a unique X.509 certificate per device, attached to exactly one thing with
AttachThingPrincipal. - Require
client/${iot:Connection.Thing.ThingName}foriot:Connectand scope publish and subscribe to the device's own topics, shadows and jobs. - Alarm on
DUPLICATE_CLIENT_IDdisconnects in CloudWatch Logs. - Remove any AWS access keys from firmware and move to the credentials provider with a role alias.
- Scope credentials provider IAM roles with
credentials-iot:ThingNameand keepcredentialDurationSecondsas short as practical. - Restrict claim certificates to provisioning topics, issue them per batch and monitor them for misuse.
- Use a pre-provisioning hook to validate serial numbers, with source ARN or source account conditions on the Lambda permission.
- Enable Device Defender audits, including the overly permissive IoT policy check, and route findings to the NHI review queue.
- Run Greengrass components and, where possible, the core software as non-root, and scope the core device service role per device group.
- Run NTP before connecting and validate the
iot.amazonaws.comserver certificate against a trusted CA store. - Deactivate and delete certificates as part of device decommissioning.
Standards and references
- AWS: Security best practices in AWS IoT Core
- AWS: Authorizing direct calls to AWS services using AWS IoT Core credential provider
- AWS: Provisioning devices that don't have device certificates using fleet provisioning
- AWS: Device Defender audit check, AWS IoT policies overly permissive
- AWS: Security best practices for AWS IoT Greengrass
- AWS: Security in AWS IoT Greengrass
- NIST: IR 8259A IoT Device Cybersecurity Capability Core Baseline
- NIST: SP 800-53 Rev. 5 (AC-6, IA-3, IA-5)
Related NHI Mgmt Group resources: Securing the IoT device management platform itself · Identity for IoT Fleets Guide · IoT Device Onboarding Guide · AWS Security Guide