-
Notifications
You must be signed in to change notification settings - Fork 9
feature: add k8s for PAM #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
a92fbc7 to
77c7b6d
Compare
f745441 to
56e8f74
Compare
Greptile OverviewGreptile SummaryThis PR adds Kubernetes support to the PAM (Privileged Access Management) system, enabling users to access Kubernetes clusters through the Infisical gateway with session auditing. The implementation follows existing patterns for SSH and database PAM proxies. Key Changes
Security & Quality Issues Found
Positive Aspects
Confidence Score: 2/5
Important Files ChangedFile Analysis
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 files reviewed, 7 comments
| // TODO: we should let the user decide whether if they want to update kubeconfig or not | ||
| // TODO: ideally, lock the files to avoid others from writing to it | ||
| // TODO: use clientcmd.ModifyConfig instead? | ||
| configLoader := clientcmd.NewDefaultClientConfigLoadingRules() | ||
| config, err := configLoader.Load() | ||
| if err != nil { | ||
| log.Fatal().Err(err).Msg("Failed to load kubernetes config") | ||
| return | ||
| } | ||
| clusterName := fmt.Sprintf("infisical-k8s-pam%s%s", actualAccountPath, accountName) | ||
|
|
||
| config.Clusters[clusterName] = &k8sapi.Cluster{ | ||
| Server: fmt.Sprintf("http://localhost:%d", proxy.port), | ||
| } | ||
| config.AuthInfos[clusterName] = &k8sapi.AuthInfo{} | ||
| config.Contexts[clusterName] = &k8sapi.Context{ | ||
| Cluster: clusterName, | ||
| AuthInfo: clusterName, | ||
| } | ||
| proxy.kubeConfigOriginalContext = config.CurrentContext | ||
| config.CurrentContext = clusterName | ||
| kubeconfig := configLoader.GetDefaultFilename() | ||
| if err = clientcmd.WriteToFile(*config, kubeconfig); err != nil { | ||
| log.Fatal().Err(err).Str("kubeconfig", kubeconfig).Msg("Failed to write kubernetes config") | ||
| return | ||
| } | ||
| log.Info().Str("kubeconfig", kubeconfig).Msg("Updated kubeconfig file") | ||
| proxy.kubeConfigClusterName = clusterName | ||
| proxy.kubeConfigPath = kubeconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Automatic kubeconfig modification without user consent
The code automatically modifies the user's kubeconfig file and switches their context. The TODO on line 109 acknowledges users should be able to opt out, but this isn't implemented. Consider adding a --no-update-kubeconfig flag.
| // TODO: ideally, lock the files to avoid others from writing to it | ||
| // TODO: use clientcmd.ModifyConfig instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Race condition: kubeconfig not locked during modification
Multiple processes could corrupt the kubeconfig if they write simultaneously. Consider using file locking (e.g., syscall.Flock) before modifying the kubeconfig.
| Use: "access-account <account-path>", | ||
| Short: "Access Kubernetes PAM account", | ||
| Long: "Access Kubernetes via a PAM-managed Kubernetes account. This command automatically launches a proxy connected to your Kubernetes cluster through the Infisical Gateway.", | ||
| Example: "infisical pam kubernetes access-account prod/ssh/my-k8s-account --duration 2h", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Example shows incorrect path
The example uses prod/ssh/my-k8s-account but should use prod/kubernetes/... or similar to match the resource type.
Description 📣
ref: https://linear.app/infisical/issue/PAM-12/add-support-for-kubernetes-resource-in-pam
Type ✨
Tests 🛠️
Please read desc in this PR:
Infisical/infisical#4981 (comment)