# Notes - Secure ZTP

## Issues with Classic ZTP <a href="#id-534e2f93-e769-466e-b527-039ebd4916a8" id="id-534e2f93-e769-466e-b527-039ebd4916a8"></a>

Classic ZTP works well in a secured environment (for example, a data center) but lacks authentication mechanisms to prevent malicious deployment of code/config.



The only security mechanisms that classic ZTP contains are:

* Whitelist device serial numbers on the DHCP server
* Use HTTPS encryption when downloading artifacts



Secure ZTP improves upon this by creating a secure workflow that is RFC-based (8572). SZTP is meant for deploying routers in the access network, particularly for 5G deployments.



## Secure ZTP Workflow <a href="#id-0098cf9c-700e-4585-b0cc-f9f0a19581ab" id="id-0098cf9c-700e-4585-b0cc-f9f0a19581ab"></a>

During manufacturing, the router has Cisco certs and a SUDI (secure unique device ID) cert burned into the hardware TAm (Trust Anchor module). The TAm is tamper-proof and implements a hardware-based trust system.



The ZTP server must be setup with a few items:

* The config, scripts, software images etc. to be pushed to the routers. These are called artifacts.
* The cert of the owner (customer) which will be used to sign the artifacts
* The ownership voucher
  * This is obtained through Cisco and signed by Cisco. This includes the device’s serial number and the owner cert, which allows the router to use a chain of trust to validate the individual artifacts. (Since the router can validate the Cisco cert due to the pre-loaded certs in TAm during manufactoring).
* Bootstrapping data
  * This is YANG modeled data which contains:
    * Conveyed information, which has either redirect information to another server, or onboarding information (image, configuration, and script names and paths to download them)
    * Owner cert
    * Ownership voucher



The router can be configured to only use secure-mode for ZTP. It seems that routers can come from the factory with this flag set so that they won’t boot into classic ZTP mode. If not, you can set this with an exec CLI command.



The router begins by running a DHCP client on its mgmt interface for v4 and v6, and then the data plane interfaces if that fails. With SZTP, the router ignores the normal bootfile options returned by the DHCP server. It only uses option 143 or option 136 (DHCPv6) which is a SZTP Redirect option. This redirects the router to the ZTP server.



The router then sends an HTTPS request to the ZTP server using the URL specified in option 143/136. This contains the device’s client certificate (SUDI). The ZTP server validates the router based on the SUDI.



The ZTP server sends the bootstrapping data to the router. The router verificates the ownership voucher by using its preconfigured Cisco trust anchor. It then uses this to validate the owner cert. It then downloads the image and other artifacts and validates these using the owner cert.



The router provisioning begins. The boot image is installed, a pre-config script is executed, the initial config is commited, and then a post-config script is executed. The router can report its status to the ZTP server (which is typically Crosswork) and Crosswork can automatically add the router to the device inventory.



## Diagrams <a href="#id-486ac531-6f02-42ca-979b-21adf02a7e00" id="id-486ac531-6f02-42ca-979b-21adf02a7e00"></a>

This slide is from the Cisco Live CCIE-SP prep presentation. This shows the differences between classic and secure ZTP:

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2Fpo72EyxH4DoQKq9fHM9Y%2Fimage.png?alt=media&#x26;token=3e4f9cc3-eca5-4889-a3fd-161865e2b6e8" alt=""><figcaption></figcaption></figure>



This is a diagram of the workflow for SZTP:

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FJYYbXk6Nn9e9m9imYahM%2Fimage.png?alt=media&#x26;token=dad050e5-ba66-46f0-9e84-05fb8edfcced" alt=""><figcaption></figcaption></figure>



## Further Reading <a href="#ab98d766-df0c-4693-9d93-387a28541b88" id="ab98d766-df0c-4693-9d93-387a28541b88"></a>

[https://www.cisco.com/c/en/us/td/docs/iosxr/ncs5xx/system-setup/73x/b-system-setup-cg-73x-ncs540/configure-secure-ztp.html](https://www.cisco.com/c/en/us/td/docs/iosxr/ncs5xx/system-setup/73x/b-system-setup-cg-73x-ncs540/configure-secure-ztp.html)

[https://www.youtube.com/watch?v=rl2ucWoTqyg\&ab\_channel=TechFieldDay](https://www.youtube.com/watch?v=rl2ucWoTqyg\&ab_channel=TechFieldDay)

[https://xrdocs.io/automation/tutorials/setting-up-crosswork-for-sztp/](https://xrdocs.io/automation/tutorials/setting-up-crosswork-for-sztp/)
