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:
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.
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.