[postfix] Obfuscate the IP on smtp-auth server #3297

Merged
zlopez merged 1 commit from zlopez/ansible:12835 into main 2026-05-05 07:52:06 +00:00
Owner

This will update configuration to clean Received header from e-mail
forwarded by smtp-auth-iso01 server to prevent leaking of internal IPs.
See infra/tickets#12835

Signed-off-by: Michal Konecny mkonecny@redhat.com

This will update configuration to clean Received header from e-mail forwarded by smtp-auth-iso01 server to prevent leaking of internal IPs. See https://forge.fedoraproject.org/infra/tickets/issues/12835 Signed-off-by: Michal Konecny <mkonecny@redhat.com>
[postfix] Obfuscate the IP on smtp-auth server
All checks were successful
Linter / yamllint (pull_request) Successful in 1m2s
Linter / ansible-lint (pull_request) Successful in 51s
AI Code Review / ai-review (pull_request_target) Successful in 16s
661e8244f8
This will update configuration to clean Received header from e-mail
forwarded by smtp-auth-iso01 server to prevent leaking of internal IPs.
See infra/tickets#12835

Signed-off-by: Michal Konecny <mkonecny@redhat.com>

AI Code Review

📋 MR Summary

This merge request updates the Postfix configuration on smtp-auth servers to strip 'Received' headers to prevent leaking internal IP addresses.

  • Key Changes:
    • Adds a custom header checks file to ignore 'Received' headers.
    • Modifies master.cf to use a new 'ascleanup' service for submissions.
    • Adds an Ansible task to copy the header checks file to target servers.
  • Impact: roles/base/files/postfix, roles/base/tasks
  • Risk Level: 🟡 Medium - While the logic for header removal is correct, file naming mismatches will cause the Ansible playbook to fail or Postfix to fail starting due to missing files.

Detailed Code Review

The approach of creating a separate cleanup service (ascleanup) and binding it to the submission service via cleanup_service_name is the correct and secure way to strip headers in Postfix without affecting other traffic. However, there is a critical typo in the file names between the actual file on disk, the Ansible copy task, and the Postfix master.cf configuration. This will break the deployment and potentially the mail service if Postfix fails to reload.

📂 File Reviews

📄 `roles/base/tasks/postfix.yml` - Adds an Ansible task to deploy the new Postfix header checks file.
  • Critical [Bug]: There is a mismatch in the filename. The created file is header_checks_submission.smtp-auth (plural 'checks'), but the src and dest in the Ansible task use header_check_submission (singular 'check'). Furthermore, master.cf expects /etc/postfix/header_checks_submission. This will cause the copy task to fail, or Postfix to fail to start.
    • Suggestion: Update the src and dest to match the actual filename and the path defined in master.cf.
- name: Install /etc/postfix/header_checks_submission file
  ansible.builtin.copy:
    src: postfix/header_checks_submission.smtp-auth
    dest: /etc/postfix/header_checks_submission
    mode: "0644"

Summary

  • Overall Assessment: A critical filename mismatch was identified that will prevent successful deployment and potentially break the Postfix service.
  • Priority Issues:
    • Fix the spelling of header_checks_submission in the Ansible task to match the committed file name and the path expected by master.cf.
  • Minor Suggestions:
    • Ensure that the postfix-pcre package is installed on the target servers, as the configuration specifically requests pcre:/etc/postfix/....

🤖 AI Code Review | Generated with ai-code-review | Model: gemini-3.1-pro-preview

⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.

## AI Code Review ### 📋 MR Summary This merge request updates the Postfix configuration on smtp-auth servers to strip 'Received' headers to prevent leaking internal IP addresses. - **Key Changes:** - Adds a custom header checks file to ignore 'Received' headers. - Modifies master.cf to use a new 'ascleanup' service for submissions. - Adds an Ansible task to copy the header checks file to target servers. - **Impact:** roles/base/files/postfix, roles/base/tasks - **Risk Level:** 🟡 Medium - While the logic for header removal is correct, file naming mismatches will cause the Ansible playbook to fail or Postfix to fail starting due to missing files. ### Detailed Code Review The approach of creating a separate cleanup service (`ascleanup`) and binding it to the submission service via `cleanup_service_name` is the correct and secure way to strip headers in Postfix without affecting other traffic. However, there is a critical typo in the file names between the actual file on disk, the Ansible copy task, and the Postfix `master.cf` configuration. This will break the deployment and potentially the mail service if Postfix fails to reload. #### 📂 File Reviews <details> <summary><strong>📄 `roles/base/tasks/postfix.yml`</strong> - Adds an Ansible task to deploy the new Postfix header checks file.</summary> - **Critical** [Bug]: There is a mismatch in the filename. The created file is `header_checks_submission.smtp-auth` (plural 'checks'), but the `src` and `dest` in the Ansible task use `header_check_submission` (singular 'check'). Furthermore, `master.cf` expects `/etc/postfix/header_checks_submission`. This will cause the copy task to fail, or Postfix to fail to start. - *Suggestion:* Update the `src` and `dest` to match the actual filename and the path defined in `master.cf`. ```` - name: Install /etc/postfix/header_checks_submission file ansible.builtin.copy: src: postfix/header_checks_submission.smtp-auth dest: /etc/postfix/header_checks_submission mode: "0644" ```` </details> ### ✅ Summary - **Overall Assessment:** A critical filename mismatch was identified that will prevent successful deployment and potentially break the Postfix service. - **Priority Issues:** - Fix the spelling of `header_checks_submission` in the Ansible task to match the committed file name and the path expected by `master.cf`. - **Minor Suggestions:** - Ensure that the `postfix-pcre` package is installed on the target servers, as the configuration specifically requests `pcre:/etc/postfix/...`. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) | **Model:** `gemini-3.1-pro-preview` ⚠️ *AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.*
zlopez force-pushed 12835 from 661e8244f8
All checks were successful
Linter / yamllint (pull_request) Successful in 1m2s
Linter / ansible-lint (pull_request) Successful in 51s
AI Code Review / ai-review (pull_request_target) Successful in 16s
to 67953a5eaa
Some checks failed
Linter / yamllint (pull_request) Successful in 27s
Linter / ansible-lint (pull_request) Failing after 45s
2026-05-04 12:55:32 +00:00
Compare
zlopez force-pushed 12835 from 67953a5eaa
Some checks failed
Linter / yamllint (pull_request) Successful in 27s
Linter / ansible-lint (pull_request) Failing after 45s
to 3f1e07dd89
All checks were successful
Linter / yamllint (pull_request) Successful in 25s
Linter / ansible-lint (pull_request) Successful in 56s
AI Code Review / ai-review (pull_request_target) Successful in 18s
2026-05-04 13:26:23 +00:00
Compare

AI Code Review

📋 MR Summary

This MR configures the smtp-auth server to obfuscate internal IP addresses by stripping Received: headers from forwarded emails.

  • Key Changes:
    • Added a new Postfix PCRE header_checks file to ignore Received: headers.
    • Updated master.cf to implement a dedicated ascleanup service for the submission port using the new header checks.
    • Added postfix-pcre package installation and deployment logic for the new header checks file to the Ansible base role.
  • Impact: roles/base/files/postfix, roles/base/tasks/postfix.yml
  • Risk Level: 🟢 Low - The changes use standard Postfix configurations (cleanup service and PCRE header checks) to enforce privacy without introducing complex logic or modifying core mail routing.

Detailed Code Review

The implementation correctly applies standard Postfix patterns to strip sensitive submission headers. Creating a dedicated cleanup service (ascleanup) tied to the submission port ensures that only authenticated submitted messages have their Received: headers stripped, rather than interfering with all mail flowing through the standard cleanup service. The Ansible tasks properly gate the file deployment to smtp-auth hosts.

📂 File Reviews

📄 `roles/base/tasks/postfix.yml` - Adds the postfix-pcre package and handles the deployment of the header checks file.
  • Minor [Suggestion]: The postfix-pcre package is added to the base package installation list, which will install it on all hosts, whereas the header checks file is only deployed on smtp-auth* hosts. If you only want this package on the smtp-auth servers, consider moving the package installation to a conditionally executed task.
    • Suggestion: Move postfix-pcre to a separate task with a when: inventory_hostname.startswith('smtp-auth') condition, or leave as is if having it on all base nodes is acceptable.

Summary

  • Overall Assessment: The changes correctly implement the requested IP obfuscation with no critical issues identified. Ready for merge.
  • Minor Suggestions:
    • Consider restricting the installation of the postfix-pcre package only to smtp-auth hosts if it is not required system-wide.

🤖 AI Code Review | Generated with ai-code-review | Model: gemini-3.1-pro-preview

⚠️ AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.

## AI Code Review ### 📋 MR Summary This MR configures the smtp-auth server to obfuscate internal IP addresses by stripping `Received:` headers from forwarded emails. - **Key Changes:** - Added a new Postfix PCRE header_checks file to ignore `Received:` headers. - Updated `master.cf` to implement a dedicated `ascleanup` service for the submission port using the new header checks. - Added `postfix-pcre` package installation and deployment logic for the new header checks file to the Ansible base role. - **Impact:** roles/base/files/postfix, roles/base/tasks/postfix.yml - **Risk Level:** 🟢 Low - The changes use standard Postfix configurations (cleanup service and PCRE header checks) to enforce privacy without introducing complex logic or modifying core mail routing. ### Detailed Code Review The implementation correctly applies standard Postfix patterns to strip sensitive submission headers. Creating a dedicated cleanup service (`ascleanup`) tied to the submission port ensures that only authenticated submitted messages have their `Received:` headers stripped, rather than interfering with all mail flowing through the standard cleanup service. The Ansible tasks properly gate the file deployment to `smtp-auth` hosts. #### 📂 File Reviews <details> <summary><strong>📄 `roles/base/tasks/postfix.yml`</strong> - Adds the postfix-pcre package and handles the deployment of the header checks file.</summary> - **Minor** [Suggestion]: The `postfix-pcre` package is added to the base package installation list, which will install it on all hosts, whereas the header checks file is only deployed on `smtp-auth*` hosts. If you only want this package on the smtp-auth servers, consider moving the package installation to a conditionally executed task. - *Suggestion:* Move `postfix-pcre` to a separate task with a `when: inventory_hostname.startswith('smtp-auth')` condition, or leave as is if having it on all base nodes is acceptable. </details> ### ✅ Summary - **Overall Assessment:** The changes correctly implement the requested IP obfuscation with no critical issues identified. Ready for merge. - **Minor Suggestions:** - Consider restricting the installation of the `postfix-pcre` package only to `smtp-auth` hosts if it is not required system-wide. --- 🤖 **AI Code Review** | Generated with [ai-code-review](https://gitlab.com/redhat/edge/ci-cd/ai-code-review) | **Model:** `gemini-3.1-pro-preview` ⚠️ *AI-generated suggestions may be incorrect. Verify before applying. Not a replacement for human review.*
Author
Owner

I think I addressed the major issue on this PR now.

I think I addressed the major issue on this PR now.
zlopez merged commit 0506d3a645 into main 2026-05-05 07:52:06 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
infra/ansible!3297
No description provided.