feat(proxy): Add support for secret update using SSE#169
feat(proxy): Add support for secret update using SSE#169
Conversation
Greptile SummaryThis PR adds demand-driven SSE (Server-Sent Events) support to the Infisical proxy, allowing real-time cache invalidation when secrets are created, updated, or deleted. When Key changes:
Issues found:
Confidence Score: 3/5Safe to merge with caveats — the authorization fix is solid, but the missing initial authentication creates a guaranteed-failure first connection per project and a small event-loss window that should be addressed before production use. The core authorization concern from the previous review cycle has been properly resolved. However, a P1 logic issue remains: SSEAuthState starts with an empty token, making every project's first SSE connection guaranteed to receive a 401. While the retry loop recovers, it introduces a window where early mutation events can be silently dropped, leaving the cache stale. The 64 KB scanner line-limit is also a real reliability gap for large batch events. Together these two issues are material enough to warrant fixes before merge. packages/proxy/sse.go — initial token not set in SSEAuthState and default scanner line-size limit both need attention. Important Files Changed
Reviews (2): Last reviewed commit: "change to use httpclient" | Re-trigger Greptile |
| proxyStartCmd.Flags().Bool("use-sse", false, "Enable SSE (Server-Sent Events) mode for real-time cache invalidation. When enabled, the static secrets refresh loop is disabled and --client-id/--client-secret are required.") | ||
| proxyStartCmd.Flags().String("client-id", "", "Universal auth client ID for SSE (required when --use-sse is enabled)") | ||
| proxyStartCmd.Flags().String("client-secret", "", "Machine identity client secret for universal auth (required when --use-sse is enabled)") |
There was a problem hiding this comment.
--client-secret passed on the command line is visible in the process list
On Linux/macOS, any user with ps aux or access to /proc/<pid>/cmdline can read all command-line arguments, including --client-secret. Consider reading the secret from an environment variable (INFISICAL_CLIENT_SECRET) or a --client-secret-file flag instead.
There was a problem hiding this comment.
@varonix0 this does not seem to be a huge problem for me, but if you think this is a security problem, I can change it to read this data from other places. I'm also curious to know what are other approaches we could use to have it better (I think that using an env variable for this might not make sense)
There was a problem hiding this comment.
This is a real security concern, especially for production environments:
Why it matters:
- Any user on the system can see it:
ps aux | grep proxyorcat /proc/<pid>/cmdline - Shell history may store it:
infisical proxy start --client-secret mysecret123 - Container orchestrators (K8s, Docker) often log command-line arguments
- Security scanners flag this pattern
Why env vars aren't much better:
- Still visible in
/proc/<pid>/environ(though slightly harder to access) - Container runtimes and orchestration systems often log them too
Best approach for your use case:
Add a --client-secret-file flag that reads from a file with restricted permissions:
clientSecretFile := cmd.Flags().GetString("client-secret-file")
if clientSecretFile != "" {
secretBytes, err := os.ReadFile(clientSecretFile)
if err != nil {
log.Fatal(err)
}
clientSecret = strings.TrimSpace(string(secretBytes))
} else {
clientSecret = cmd.Flags().GetString("client-secret")
}Usage:
echo "mysecret" > /etc/infisical/client-secret
chmod 600 /etc/infisical/client-secret
infisical proxy start --client-secret-file /etc/infisical/client-secretThis is the standard pattern used by production tools (Docker, Kubernetes secrets, etc.) and works well in containerized environments where secrets are mounted as files.
|
@greptile check the comments added and the changes. See if the problems still make sense. Update the summary |
| m.removeConnection(conn.ProjectID) | ||
| return |
There was a problem hiding this comment.
@varonix0 I thought about creating a fallback to the pooling policy in case this happens. The idea is to call the resync static here in a go routine, using a new context. I would also create a new context inside the SSEManager so it is possible to cancel it when the SSE connection happens again. But I'm not sure if this makes sense here, please let me know what you think
Description 📣
Allow support to update secrets using SSE (server sent events)
Type ✨
Tests 🛠️