Skip to content

Security Hardening, Microsoft Account Intelligence, and IPC Reliability

Latest

Choose a tag to compare

@tirthsaraiya29 tirthsaraiya29 released this 21 Nov 17:53
· 47 commits to main since this release

Overview

Tether v1.2.3 is a focused security and reliability release that introduces comprehensive hardening across the Windows Credential Provider, IPC named pipe and event infrastructure, and the session helper's application launch surface. This release also delivers automatic Microsoft Account detection with adaptive onboarding UI, resolves multiple desktop interface layout regressions, and adds persistent paired device caching for immediate visibility at launch.


New Features

Microsoft Account Auto-Detection and Adaptive UI

A new WindowsAccountDetector component automatically identifies whether the active Windows session is backed by a Microsoft Account (MSA), a local account, or a domain account at application startup.

  • Win32 NetUserGetInfo Level 24 Integration: The detector calls NetUserGetInfo at level 24 to query the USER_INFO_24 structure, extracting the usri24_internet_identity flag, the internet provider name, and the internet principal name (e.g., user@outlook.com). Fallback detection checks the IdentityCRL registry hive and token group SIDs when the primary call is unavailable or returns inconclusive results.
  • Dynamic Sidebar Identity Display: The sidebar "Current Account" card now renders a contextual badge pill ("MICROSOFT ACCOUNT", "LOCAL ACCOUNT", or "DOMAIN ACCOUNT") alongside the detected account identity. The SAM profile alias and Microsoft Account email principal are displayed as appropriate for the account type.
  • Adaptive Auto-Unlock Setup: The credential vault setup card dynamically adjusts its title, description, placeholder text, and security disclaimer based on the detected account type. Microsoft Account users are prompted for their online account password with explicit guidance that Windows Hello PINs cannot be used for credential provider unlock. Local account users see standard local password prompts.
  • Passwordless Microsoft Account Notice: An inline guidance panel with an external documentation link is displayed for passwordless Microsoft Account configurations (Windows Hello-only setups) explaining the limitation and directing users to set an app password.
  • Pre-Save Credential Validation: Entered credentials are validated in real time against LogonUser (Win32) before being committed to the DPAPI-encrypted store. The validator detects common mistakes including PIN entry (4-10 digit numeric strings), expired passwords (ERROR_PASSWORD_EXPIRED), disabled accounts (ERROR_ACCOUNT_DISABLED), and incorrect passwords (ERROR_LOGON_FAILURE), returning clear, account-type-aware error messages. Validation attempts multiple candidate (username, domain) pairs including MSA-specific "MicrosoftAccount" domain, SAM name with local domain, and dot-domain fallbacks, using both LOGON32_LOGON_INTERACTIVE and LOGON32_LOGON_NETWORK logon types.
  • Forgot Password Recovery Card: Account-type-aware copy is applied to the recovery flow so that Microsoft Account users are asked for their online password while local users are asked for their Windows password.

Persistent Paired Device Caching

Paired phone devices now appear immediately on application launch, even when the communication service is still starting or the phone is temporarily disconnected.

  • Local Device Cache (DesktopUI): The desktop UI reads and writes a local paired device cache at %LocalAppData%\Tether\paired_devices.json. On startup, cached device entries (including device ID, display name, fingerprint, and last-seen timestamp) are loaded and rendered in the sidebar before the service connection is established.
  • Public Summary Cache (TrustStore): The TrustStore now writes a paired_devices_cache.json summary file alongside the trust data in %ProgramData%\Tether, with Authenticated Users granted read access to the trust store directory and file. This enables the non-elevated desktop UI process to read paired device state without requiring administrative privileges.
  • PROVISION_PHONE Event: The PairingManager now publishes a PROVISION_PHONE event over the internal event bus upon successful phone pairing completion, carrying a JSON payload of all currently trusted devices. The desktop UI requests a telemetry sync with retries on startup to ensure the cache is populated.

Security

Credential Provider COM Interface Hardening

Every public COM interface method in CTetherCredential has been hardened with structured exception handling and rigorous parameter validation.

  • SEH and C++ Exception Guards: The Initialize method is now wrapped in a try/catch(...) block returning E_UNEXPECTED on unhandled exceptions, matching the existing pattern applied to other COM methods. This prevents unhandled C++ exceptions from propagating across the COM boundary on the secure desktop (Winlogon).
  • E_POINTER Validation: Null output pointer checks (E_POINTER) have been added to SetSelected, GetFieldState, GetStringValue, GetBitmapValue, GetSubmitButtonValue, GetComboBoxValueCount, GetComboBoxValueAt, GetFieldOptions, ReportResult, and GetUserSid. Output pointers are pre-initialized to nullptr where applicable before any work is performed.
  • E_INVALIDARG Validation: The Initialize method now validates all three input pointers (pcpUser, rgcpfd, rgfsp) before proceeding, up from checking only pcpUser.

Plaintext Password Memory Zeroing

All code paths that handle plaintext password buffers in the credential provider now zero memory before deallocation to prevent password remnants from persisting in the process address space.

  • SetStringValue: When the password field (SFI_PASSWORD) is overwritten, the previous buffer is zeroed with SecureZeroMemory over its full wcslen * sizeof(WCHAR) extent before CoTaskMemFree.
  • _PackActualPasswordCredential: Intermediate plaintext password copies are zeroed with SecureZeroMemory before being freed via CoTaskMemFree.
  • _GetStoredPasswordAndPack: Decrypted password buffers are zeroed after use.
  • helpers.cpp / ProtectIfNecessaryAndCopyPassword: Both pwzProtected and pwzToProtectCopy buffers are zeroed with SecureZeroMemory before CoTaskMemFree. Null checks guard against double-free on already-freed pointers.

IPC Named Event Security Overhaul

The global named events used for inter-process communication between the credential provider, the communication service, and the desktop UI (TetherPhoneAppUnlocked, TetherPhoneConnected, TetherUnlockPromptRequested) have been redesigned for a consistent "open-or-create" pattern with strengthened DACLs.

  • Updated SDDL: All global IPC events now use the SDDL string D:P(A;;GA;;;SY)(A;;GA;;;BA)(A;;GR;;;AU), granting SYSTEM and Administrators full generic access while granting Authenticated Users read-only (generic read) access. The previous SDDL D:P(A;;GA;;;SY)(A;;GA;;;BA) excluded Authenticated Users entirely, which caused UnauthorizedAccessException failures when the desktop UI (running as a standard user) attempted to open events with Synchronize rights.
  • TryOpenExisting Pattern (Service Side): Worker.cs and HardwareExecutor.cs now use EventWaitHandleAcl.TryOpenExisting to open pre-existing events with only the minimum required rights (Modify | ReadPermissions, or Modify | ReadPermissions | Synchronize), eliminating the previous pattern of always creating events and then checking createdNew. This avoids requesting WRITE_DAC permission on events owned by SYSTEM, which standard-user processes cannot obtain.
  • DACL Re-stamping: When an existing event is opened and passes the trusted-owner check, its DACL is re-stamped via SetKernelObjectSecurity to enforce the current expected SDDL, ensuring that events created by older versions with weaker DACLs are upgraded in place.
  • Credential Provider (Native): The native C++ credential provider (TetherCredential.cpp) applies the same "create-then-verify" pattern with the updated SDDL. The IsTrustedKernelObjectOwner helper is used consistently to validate that existing events are owned by SYSTEM or Administrators before signaling.
  • Desktop UI (Managed): MainWindow.xaml.cs opens global unlock events via EventWaitHandleAcl.TryOpenExisting with Synchronize-only rights, the minimum needed to wait on the event without requiring write or modify permissions.

Named Pipe Security Hardening

All NamedPipeServerStream instances across the communication service have been updated to explicitly deny the Anonymous SID (WellKnownSidType.AnonymousSid) in addition to the existing Network SID denial.

  • PipeServer: CreatePipeSecurity() now includes an explicit Deny ACE for AnonymousSid with ReadWrite rights. The method visibility was changed from private to internal to support unit testing. The access rule ordering is documented with numbered comments.
  • InputForwarder: The input forwarding pipe security descriptor adds an explicit AnonymousSid deny rule.
  • App.xaml.cs (DesktopUI): The desktop UI's local pipe security descriptor adds the same AnonymousSid deny rule.

Application Launch Command Injection Prevention

ApplicationManager.LaunchApplication in the session helper has been hardened against command injection, shell metacharacter exploitation, and execution of dangerous binaries.

  • Control Character Rejection: Paths and arguments containing any control characters (including null bytes, newlines, and carriage returns) are rejected.
  • Shell Metacharacter Blocking: Paths and arguments containing command chaining and redirection operators (&, |, <, >, ^, ;, `) are rejected.
  • Interpreter Blocklist: A static set of blocked binary names (cmd, powershell, pwsh, mshta, cscript, wscript, bash, wsl, sh, reg, vssadmin) prevents direct invocation of shell interpreters and system-modifying tools, checked against both the full filename and the filename without extension.
  • Script Extension Blocklist: Files with dangerous executable script extensions (.bat, .cmd, .ps1, .psm1, .vbs, .vbe, .js, .jse, .wsf, .wsh, .hta, .msc, .reg) are blocked from launch.

Shell Execution Hardening

  • Browser and Settings Launch: HardwareExecutor no longer uses cmd.exe /c start to launch browser URLs or Windows Settings URIs. These are now launched directly via explorer.exe, eliminating cmd.exe as an intermediary and reducing the attack surface for command injection through crafted capability payloads.

PowerCfg Argument Injection Prevention

  • ProcessStartInfo.ArgumentList: WindowsAdminManager powercfg invocations for battery report generation and power scheme activation have been refactored from string-based Arguments to the array-based ArgumentList API (psi.ArgumentList.Add(...)). This prevents argument injection through specially crafted power scheme GUIDs or file paths, as the runtime handles escaping and quoting automatically.

Bug Fixes

Audio Mute State Query

  • get-mute Exit Code Handling: HardwareExecutor now correctly interprets exit codes from the audio helper when the get-mute subcommand is invoked. Previously, only exit code 0 was treated as a valid result for numeric queries. The mute state query now recognizes both exit code 0 (unmuted) and exit code 1 (muted) as valid responses, and stores the exit code directly as the numeric result. This fixes incorrect "mute state unavailable" errors when the system audio was muted.

IPC Named Event Permission Errors

  • WRITE_DAC Access Denied: Opening existing named events with EVENT_MODIFY_STATE | READ_CONTROL | WRITE_DAC permissions (as was done implicitly by the previous Create-with-createdNew pattern) failed with ACCESS_DENIED when the event was owned by SYSTEM and the caller was a standard user process. The new TryOpenExisting pattern requests only the minimum required rights, resolving sporadic UnauthorizedAccessException errors during service startup and event signaling.

Desktop UI Layout Corrections

  • Sidebar Column Width: The sidebar navigation column has been widened from 236px to 260px to accommodate Microsoft Account email addresses and the new account type badge pill without truncation.
  • Account Card Typography: Font sizes, padding, and margins in the user account card have been adjusted (font size reduced from 9.5 to 8.5 for the "CURRENT ACCOUNT" label, card margins tightened from 12px to 10px, inner stack margin from 10px to 9px) to prevent text crowding when longer email addresses are displayed.
  • CardVault Security Banner: The lock icon and descriptive text in the credential vault setup card no longer overlap. Grid.Column assignments have been corrected and TextWrapping has been enabled on the description text block.
  • Paired Phones Section Visibility: Vertical margins on the Microsoft Account card and surrounding elements have been streamlined to ensure the "Paired Phones" section remains visible within the viewport without excessive scrolling.

Test Coverage

Native Test Suite (C++)

  • Test_CredentialProvider_Initialize_NullArgs_Rejected: Verifies that CTetherCredential::Initialize returns E_INVALIDARG when called with null rgcpfd, rgfsp, or pcpUser pointers.
  • Test_CredentialProvider_COM_PointerChecks: Comprehensive null-pointer validation test covering SetSelected, GetFieldState, GetStringValue, GetBitmapValue, GetSubmitButtonValue, GetComboBoxValueCount, GetComboBoxValueAt, GetFieldOptions, ReportResult, and GetUserSid. Each method is verified to return E_POINTER when called with null output parameters.
  • Test_CredentialProvider_SetStringValue_ZeroesOldPassword: End-to-end test using a MockCredentialProviderUser that initializes a credential, sets a password, verifies it via GetStringValue, then overwrites it and verifies the new value is returned correctly, confirming that the zeroing and replacement logic does not corrupt field state.

.NET Test Suite (xUnit)

  • EventSecurityDescriptor_AllowsSystemAndAdminsFullControl_AndAuthenticatedUsersReadOnly: Updated to validate the new three-ACE SDDL structure with exact ACE string assertions ((A;;GA;;;SY), (A;;GA;;;BA), (A;;GR;;;AU)) and confirms the absence of Anonymous (AN) and Everyone (WD) SIDs.
  • PipeServerSecurity_DeniesNetworkAndAnonymous_AllowsLocalSystemAndAdmins: New test that instantiates the production PipeServer.CreatePipeSecurity() method and iterates all access rules to verify that Network and Anonymous SIDs are denied, SYSTEM and Administrators are allowed, and Authenticated Users are allowed.
  • ApplicationManagerTests: New test class with three theory-based test methods:
    • LaunchApplication_RejectsControlCharacters: Verifies rejection of paths containing newlines, tabs, null bytes, and embedded control sequences.
    • LaunchApplication_BlocksShellInterpreters: Verifies rejection of cmd.exe, powershell.exe, pwsh.exe, mshta.exe, cscript.exe, wscript.exe, bash.exe, wsl.exe, and their extensionless variants, including fully qualified paths.
    • LaunchApplication_BlocksScriptExtensions: Verifies rejection of files with .bat, .cmd, .ps1, .psm1, .vbs, .hta, and .reg extensions.

Infrastructure

  • Version Bumps: Installer (Tether.iss) updated from 1.2.1 to 1.2.3. Android companion app (build.gradle.kts) updated from version name 1.2.2 / version code 4 to version name 1.2.3 / version code 6.
  • PipeServer Visibility: CreatePipeSecurity() changed from private to internal to enable direct unit testing of the pipe security descriptor construction.

Files Changed

Component Files Modified Lines Added Lines Removed
Credential Provider (C++) TetherCredential.cpp, helpers.cpp ~350 ~290
Desktop UI (WPF) MainWindow.xaml, MainWindow.xaml.cs, App.xaml.cs, WindowsAccountDetector.cs (new) ~700 ~215
Communication Service HardwareExecutor.cs, WindowsAdminManager.cs, PipeServer.cs, InputForwarder.cs, Worker.cs, TrustStore.cs, PairingManager.cs ~970 ~900
Session Helper ApplicationManager.cs ~46 0
Tests main.cpp, ApplicationManagerTests.cs (new), GlobalNamedEventTests.cs ~265 ~7
Build/Installer Tether.iss, build.gradle.kts ~4 ~4
Total 19 files ~2,428 ~1,299

Upgrade Notes

  • This release requires no configuration changes. All security hardening is applied automatically on upgrade.
  • Existing global IPC events created by v1.2.2 or earlier will have their DACLs upgraded in place on first access by the v1.2.3 service or credential provider.
  • The paired_devices_cache.json file in %ProgramData%\Tether will be created automatically on the next trust store write operation.
  • The paired_devices.json file in %LocalAppData%\Tether will be created automatically by the desktop UI on first successful paired device sync.