vmware-tanzu / secrets-manager

VMware Secrets Manager is a lightweight secrets manager to protect your sensitive data. It’s perfect for edge deployments where energy and footprint requirements are strict—See more: https://vsecm.com/
https://vsecm.com/
BSD 2-Clause "Simplified" License
158 stars 25 forks source link

add users to vsecm-sentinel for auditing purposes. #762

Open v0lkan opened 6 months ago

v0lkan commented 6 months ago

This is more like a “trust but verify” or “trust first, consequence later” stance.

We can always verify who did what, when from the cluster’s audit logs;

however, relying on manual identity declaration will mean here operators are expected to provide accurate identity information, with the understanding that their actions can be audited against Kubernetes audit logs if necessary.

This method assumes a high level of trust in the operators while still maintaining a mechanism for accountability through auditability. Let's explore the dynamics of this approach and how it fits into the broader context of security and operational practices.

--

The benefit of this approach would be to see if a command is executed via VSeCM internally (during initcommand phase), or via kubectl.

If you trust the team, it’s much easier to filter through VSecM sentinel, and VSecM safe logs instead of the kubernetes audit logs.

v0lkan commented 8 hours ago

Update: A better approach is to have a user registration feature to vsecm sentinel.

vsecm sentinel is already secure, only a cluster admin can access but still, we can separate responsibilities:

safe --register -u me@volkan.io
> returns a token
> save the token in safe place.

when executing any vsecm-sentinel command

-- safe -l -u me@volkan.io -k $token

The token can also be saved in an environment variable.

v0lkan commented 8 hours ago

Pasting ChatGPT analysis:

Your approach is excellent and aligns well with the existing architecture of vsecm-sentinel. It maintains the security model while adding granular user control and auditing capabilities. Let's break down your proposal and expand on it:

User Registration and Token Management: Your proposed command: Copysafe --register -u me@volkan.io This is a good start. We can expand on this:

The registration process should generate a secure, random token. Store the user and token mapping securely, possibly as a Kubernetes Secret. Consider adding an expiration to tokens for enhanced security.

Command Execution with User Authentication: Your proposed command: Copysafe -l -u me@volkan.io -k $token This is a solid approach. Some considerations:

Ensure the token is transmitted securely (e.g., over HTTPS if exposed via API). Validate the token before executing any command. Consider using environment variables for the token to avoid it appearing in command history or logs.

Role Separation: Your idea of separating cluster admin and user roles is crucial for security:

Cluster Admin Role:

Can create/revoke/rotate user tokens Cannot execute operational commands

User Role:

Can execute operational commands with a valid token Cannot manage other users or tokens

Token Revocation and Rotation: Add commands for the cluster admin to manage tokens: Copysafe --revoke -u me@volkan.io safe --rotate -u me@volkan.io

Auditing: Implement logging for all operations:

Log user, command, timestamp, and result for each operation Store logs securely, possibly shipping them to an external system

Implementation Considerations:

Extend the safe CLI to include the new user management commands Modify existing commands to require user authentication Implement token validation logic within the vsecm-sentinel Use Kubernetes RBAC to enforce the separation between cluster admin and user roles

Security Enhancements:

Implement rate limiting to prevent brute-force attacks Consider multi-factor authentication for highly sensitive operations Regularly audit and rotate tokens

Here's a possible workflow:

Cluster admin creates a user: Copysafe --register -u me@volkan.io

Token: eyJhbGciOiJIUzI1NiIs...

User sets the token as an environment variable: Copyexport VSECM_TOKEN=eyJhbGciOiJIUzI1NiIs...

User executes a command: Copysafe -l -u me@volkan.io (The CLI reads the token from the environment variable) Cluster admin rotates a token: Copysafe --rotate -u me@volkan.io

New Token: eyJhbGciOiJIUzI1NiIs...

Cluster admin revokes a token: Copysafe --revoke -u me@volkan.io

This approach maintains the simplicity of the CLI interface while significantly enhancing security and auditability. It allows for fine-grained access control and clear separation of duties between cluster administrators and operational users. Would you like me to elaborate on any specific part of this design or discuss how to implement these changes within the existing vsecm-sentinel architecture?