Tuesday, 7 January 2025

Filled under:

 Here’s a draft for a GitLab issue to highlight the problem and the required remediation:



---


Title: Restrict Execution of patronictl Commands to Authorized Users Only



---


Description


It has been observed that across multiple servers, the patronictl command can be executed by normal (non-postgres) users. This poses a potential security risk as patronictl is used to manage Patroni clusters for PostgreSQL, which could lead to unauthorized actions affecting the database cluster.


Current Issue


The patronictl executable has permissions that allow execution by users who are not part of the postgres group or have not switched to the postgres user (su - postgres).


This issue affects the security and integrity of the database clusters managed by Patroni.




---


Impact


Unauthorized access to patronictl commands may result in:


Unintended changes to cluster state (e.g., failover, demotion, etc.).


Potential disruption of database services.


Violation of security and compliance policies.





---


Proposed Solution


1. Modify Ownership and Permissions for patronictl:


Ensure patronictl is owned by the postgres user and group:


chown postgres:postgres /path/to/patronictl


Restrict permissions so that only the postgres user can execute it:


chmod 700 /path/to/patronictl




2. Restrict Access to postgres User:


Verify and restrict the ability of users to switch to the postgres user (su - postgres) by reviewing /etc/sudoers and other access control mechanisms.




3. Validation Steps:


After applying the changes, confirm that:


Non-postgres users cannot execute patronictl.


Only the postgres user (or users explicitly authorized via sudo) can operate patronictl.





4. Apply Changes Estate-Wide:


Roll out these changes across all servers in the estate where Patroni is deployed.


Perform validation checks after rollout to ensure compliance.






---


Tasks


1. Audit servers to identify current permissions of the patronictl executable.



2. Update ownership and permissions for patronictl on all servers.



3. Restrict access to the postgres user via sudoers or other mechanisms.



4. Perform validation testing on all servers.



5. Document changes for future reference.





---


Priority: High


This issue requires immediate attention to prevent potential misuse or unauthorized actions affecting PostgreSQL clusters.



---


References


Patroni Documentation


PostgreSQL Best Practices




---


Does this look good, or would you like any further modifications?


0 comments:

Post a Comment