Skip to content

Windows Firewall self-check always fails for non-administrator users #2

Open

Description

@javadhamed-ctrl

Summary

TwinDesk's firewall self-check (windows/firewall.js -> check()) runs PowerShell non-elevated. On Windows, Get-NetFirewallApplicationFilter returns an empty result for non-administrator users, so the check always reports "TwinDesk isn't allowed through Windows Firewall on this network." and discovery stays blocked in the UI even when the firewall rules are correctly in place.

Root cause

In windows/firewall.js:

async function check(exe = process.execPath) {
  try {
    return { ...interpret(JSON.parse(await powershell(statusScript(exe)) || '{}')), checkedAt: Date.now() };
  } catch (e) { ... }
}

powershell (i.e. run) invokes PowerShell without elevation. The status script relies on Get-NetFirewallApplicationFilter | Where-Object { $_.Program -eq $exe }, which requires elevation to return results for non-admin users. Hence rules is always empty, covered is always false, and ok is always false.

Suggested fix

Either:

  1. Run the status check elevated and read the result from a file (note: runElevated loses stdout, so the script must write to a temp file; also strip the UTF-8 BOM that PowerShell 5.1 writes with Out-File -Encoding utf8), or
  2. Replace the Get-NetFirewallApplicationFilter-based query with netsh advfirewall firewall show rule name="TwinDesk", which can be read without elevation.

Fork

I created a fork that implements option (1) and also adds the missing firewall rules (TCP 47800 / UDP 47801, inbound+outbound, all profiles): https://github.com/javadhamed-ctrl/TwinDesk

Anyone who wants the fix can use that fork.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions