Other A risk to be aware of using Ansible templates

I have been using Ansible for more than a decade but only today did I have the realization that my use of Ansible templates could unknowingly introduce a security vulnerability.

I am guilty of not reading every FreeBSD Security Advisory before using freebsd-update. However, I will try to read them all now. The recent advisory for bsnmpd contained the following workaround which was not in my template:

Systems which do not use SNMPv3 can avoid CVE-2026-127742 by enabling
only SNMPv1 and SNMPv2c. Add the following line to the %snmpd section of
/etc/snmpd.config and restart bsnmpd(1):

begemotSnmpdVersionEnable = 3

CVE-2026-127743 can then be triggered only by clients with write access
to the agent.

Immediately after reading the advisory, I modified my Ansible template accordingly and then I realized that I may have missed many other security advisories in the past that required configuration file changes.

In my defense, I do use the Ansible template backup feature to help identify differences between a package installed config file and an Ansible deployed templated version. Sadly, I have not been sufficiently diligent to regularly look for changes that created backup versions.

I am going to have to think about how I can manage this problem effectively. I will start now by reading the Security Advisories before running freebsd-update. I will continue to use Ansible templates, but I need to create an automatic alerting system that can spot upstream config file changes. My initial idea for this is using Ansible lineinfile for configuration comparisons.

I use conditional branching and inheritance a lot in my production Ansible templates which makes them smaller than the sample configs. I could adapt them to make additional full sample configurations that are stored in a non-active local 'compare' folder. Additional Ansible tasks would be required to create a second 'lineinfile' version of an upstream recommended config that was modified to contain my local deployment data. In theory, the non-active full templated version should generate exactly the same output as the lineinfile version. Ansible could detect upstream changes by deploying the full templated version to the same destination as the previously created lineinfile version, halting the play when a change was detected between lineinfile and template versions. The actual real working config would still be generated (if need be) by my Ansible template when the 'compare' folder version had no changes.

I guess I would need to write a code generator that could create a lineinfile task sequence and a matching template from inputs of an unmodified upstream sample config and a locally adapted config file.
 
In all honesty, I don't quite see how this problem necessarily pertains to Ansible, or any other such tool, or even hand-editing for that matter, because any of those mechanisms could have just as easily (re-)introduced the problem by editing the file in question in an undesirable way. The only requirement for that to happen is for the tool/person performing the edit to be, in whatever applicable way, unaware of the undesired configurations, and I think it's pretty easy to conclude that's well outside the scope of orchestration tools such as Ansible.
 
Ah, the Security Not My Problem daemon issues.

But not to just spam; as guys above mentioned, this is not particular to any orchestration tool. It's good to keep track of SAs, as you said.
 
How, exactly, is Ansible's responsibility to be aware that, by executing an instruction that you are telling it to execute, i.e. copying a file into place, it is reintroducing a vulnerability to a specific CVE?
If you read my post again you may notice I didn't hint such thing anywhere.
 
Back
Top