Skip to content

feat(chore/windows): move socket path#482

Merged
joe0BAB merged 1 commit intomainfrom
x/path
Mar 5, 2026
Merged

feat(chore/windows): move socket path#482
joe0BAB merged 1 commit intomainfrom
x/path

Conversation

@joe0BAB
Copy link
Collaborator

@joe0BAB joe0BAB commented Mar 5, 2026

No description provided.

Signed-off-by: Johannes Großmann <grossmann.johannes@t-online.de>
@joe0BAB joe0BAB self-assigned this Mar 5, 2026
@joe0BAB joe0BAB requested a review from Benehiko March 5, 2026 09:49
@joe0BAB joe0BAB marked this pull request as ready for review March 5, 2026 09:49
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Assessment: 🔴 CRITICAL

This PR changes the Windows socket path from ProgramData (system-wide) to LOCALAPPDATA (user-specific). While this may be intentional, the implementation has critical bugs that will break existing installations and could cause runtime failures.

Critical Issues Found

  1. Broken fallback path logic - Can produce relative paths instead of absolute paths
  2. Breaking change without migration - No upgrade path for existing installations
  3. Undocumented security model change - Shifts from system-wide to user-specific without justification

Details

All 3 issues are in the newly changed code and were verified to be real bugs.


This review focuses only on the changed code. Pre-existing code was not evaluated.

base := os.Getenv("LOCALAPPDATA")
if base == "" {
base = `C:\ProgramData`
base = filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Local")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH SEVERITY - Missing validation for USERPROFILE environment variable

If both LOCALAPPDATA and USERPROFILE environment variables are unset or empty, os.Getenv("USERPROFILE") returns an empty string. This causes filepath.Join("", "AppData", "Local") to produce a relative path "AppData\Local" instead of an absolute path.

This could cause:

  • Socket created in unexpected location (current working directory)
  • Connection failures between daemon and client
  • Security issues if processes have different working directories

The old code had a hardcoded absolute fallback (C:\ProgramData), which prevented this issue.

Recommendation: Add validation for USERPROFILE or use a hardcoded absolute fallback:

if base == "" {
    userProfile := os.Getenv("USERPROFILE")
    if userProfile == "" {
        base = `C:\Users\Default\AppData\Local`  // or another safe default
    } else {
        base = filepath.Join(userProfile, "AppData", "Local")
    }
}


func DaemonSocketPath() string {
base := os.Getenv("ProgramData")
base := os.Getenv("LOCALAPPDATA")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH SEVERITY - Breaking change without migration path

This change moves the socket from ProgramData (typically C:\ProgramData) to LOCALAPPDATA (typically C:\Users\<username>\AppData\Local). This breaks backward compatibility:

  • Existing installations will have the socket in the old location
  • After upgrade, the daemon creates a socket in the new location
  • Clients using the old path will fail to connect
  • No automatic cleanup of old sockets
  • No fallback mechanism to check the old location

Impact: Systems will be left in an inconsistent state during upgrades.

Recommendations:

  1. Add migration logic to move/cleanup old socket
  2. Implement fallback to check old location if new one doesn't exist
  3. Document the upgrade path
  4. Consider a configuration option for backwards compatibility


func DaemonSocketPath() string {
base := os.Getenv("ProgramData")
base := os.Getenv("LOCALAPPDATA")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM SEVERITY - Security model change without justification

This changes the security model from system-wide (ProgramData, requires admin privileges) to user-specific (LOCALAPPDATA, user-writable).

Potential issues:

  1. Multi-user scenarios: Socket now accessible only to specific user, potentially breaking shared daemon usage
  2. Privilege escalation risks: If daemon runs as SYSTEM but uses user's LOCALAPPDATA
  3. Deployment model change: Multiple users might create conflicting daemon instances

Recommendation: Document the intended security model and deployment scenario. If this change is intentional, add comments explaining:

  • Why the move from system-wide to user-specific
  • Expected privilege level for the daemon
  • How multi-user scenarios should be handled

@joe0BAB joe0BAB merged commit 42b31f0 into main Mar 5, 2026
17 checks passed
@joe0BAB joe0BAB deleted the x/path branch March 5, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants