Skip to content

feat: add "privacy" security preset to disable Windows telemetry (#43) - #63

Closed
Prateek2007-cmd wants to merge 4 commits into
DotDev262:mainfrom
Prateek2007-cmd:feature/privacy-preset-43
Closed

feat: add "privacy" security preset to disable Windows telemetry (#43)#63
Prateek2007-cmd wants to merge 4 commits into
DotDev262:mainfrom
Prateek2007-cmd:feature/privacy-preset-43

Conversation

@Prateek2007-cmd

Copy link
Copy Markdown

Summary

Closes #43

Adds a new "privacy" security preset to _securityPresets in SystemSettingsService.cs that disables common Windows telemetry and privacy-intrusive features via safe, non-destructive registry tweaks.

Changes

src/Services/System/SystemSettingsService.cs

Added a "privacy" entry to the _securityPresets dictionary with 8 registry tweaks:

Registry Key Value Name Value Purpose
HKLM\...\DataCollection AllowTelemetry 0 Disable Windows telemetry data collection
HKCU\...\AdvertisingInfo Enabled 0 Disable Advertising ID
HKLM\...\Windows\System EnableActivityFeed 0 Disable Activity History
HKLM\...\Windows\System UploadUserActivities 0 Disable Activity History cloud sync
HKCU\...\Privacy TailoredExperiencesWithDiagnosticDataEnabled 0 Disable tailored experiences
HKCU\...\Siuf\Rules NumberOfSIUFInPeriod 0 Disable feedback prompts
HKCU\...\InputPersonalization RestrictImplicitTextCollection 1 Disable text/ink data collection
HKCU\...\TrainedDataStore HarvestContacts 0 Disable contact harvesting

tests/WinHome.Tests/SystemSettingsServiceTests.cs

Added 3 new unit tests:

  • GetTweaksAsync_Should_Return_Privacy_Preset_Tweaks — verifies exactly 8 tweaks are returned
  • GetTweaksAsync_Privacy_Preset_Should_Contain_Expected_Registry_Keys — asserts each registry key/value individually
  • GetTweaksAsync_Should_Return_Empty_For_Unknown_Preset — edge case for unknown presets

Design Decisions

  • Standalone presetprivacy is independent from baseline/strict, so users can apply privacy tweaks without affecting security hardening and vice versa
  • All dword type — consistent with existing presets; no string-type values
  • Zero destructive modifications — all tweaks target telemetry/tracking features that are safe to disable
  • Preserves existing architecture — follows the exact same pattern as baseline and strict

Usage

security_preset: privacy

@Prateek2007-cmd

Copy link
Copy Markdown
Author

Hi @DotDev262👋

The implementation for this feature has been completed and submitted in this PR.

Kindly review the changes, and if everything looks good, please add the relevant labels such as gssoc:approved and other applicable GSSoC labels to the PR. Thank you!

@DotDev262

Copy link
Copy Markdown
Owner

Could you give an executed output screenshot

@Prateek2007-cmd

Copy link
Copy Markdown
Author
image Hi @DotDev262👋

I’ve completed the implementation and successfully verified the changes locally. All tests are passing successfully, including the related preset and registry behavior tests.

If everything looks good from your side, kindly review the PR and please add the relevant GSSoC labels such as gssoc:approved and other applicable labels. Thank you!

@DotDev262

Copy link
Copy Markdown
Owner

In the output , it tells the unit test hasn't tested the privacy profile , can you like execute it in a vm to see if it changes those registry values.

Iam asking in a vm since the tool can corrupt your windows install if the config is setup wrongly

@Prateek2007-cmd

Copy link
Copy Markdown
Author

That makes sense, thanks for pointing it out.

The current tests follow the same pattern used by the existing baseline and strict presets in the project. The unit tests verify that the privacy preset generates the correct registry tweak definitions (paths, keys, and values), while the actual registry application logic is already covered separately in RegistryServiceTests.

I avoided performing direct registry modification tests during unit testing to keep the test suite environment-safe and consistent with the existing architecture.

That said, I understand the concern regarding potentially unsafe registry configurations. I can additionally validate the preset behavior in an isolated VM environment and confirm that the registry values are applied correctly without affecting system stability.

@DotDev262 DotDev262 added GSSOC GirlScript Summer of Code 2026 gssoc:approved Approved for GSSOC points (Required) labels May 19, 2026
@DotDev262 DotDev262 self-assigned this May 19, 2026
@DotDev262

Copy link
Copy Markdown
Owner

Tested it out this doesn't work if they key or dword doesn't exist in the first place

@Prateek2007-cmd

Copy link
Copy Markdown
Author

hi @DotDev262 ,Thanks for pointing out the edge case.

I’ve updated the implementation to properly handle scenarios where the registry key or DWORD value does not already exist. The fix now safely creates missing keys/values, adds additional null-safety handling, and improves robustness for clean/default Windows setups.

I also added a regression test covering the missing-key scenario and verified the registry-related tests locally after the fix.

The latest changes have been pushed to the existing PR.

@DotDev262

Copy link
Copy Markdown
Owner

Run the preset inside a vm and shared the screenshot of the verified output of this powershell script in Administrator Mode

# verify-privacy-preset.ps1 (ROBUST VERSION)
$tweaks = @(
    [PSCustomObject]@{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "AllowTelemetry"; Expected = 0; Description = "Disable Telemetry" }
    [PSCustomObject]@{ Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo"; Name = "Enabled"; Expected = 0; Description = "Disable Advertising ID" }
    [PSCustomObject]@{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"; Name = "EnableActivityFeed"; Expected = 0; Description = "Disable Activity History" }
    [PSCustomObject]@{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"; Name = "UploadUserActivities"; Expected = 0; Description = "Disable Activity History Cloud Sync" }
    [PSCustomObject]@{ Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Privacy"; Name = "TailoredExperiencesWithDiagnosticDataEnabled"; Expected = 0; Description = "Disable Tailored Experiences" }
    [PSCustomObject]@{ Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Siuf\Rules"; Name = "NumberOfSIUFInPeriod"; Expected = 0; Description = "Disable Feedback Prompts" }
    [PSCustomObject]@{ Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\InputPersonalization"; Name = "RestrictImplicitTextCollection"; Expected = 1; Description = "Restrict Text/Ink Collection" }
    [PSCustomObject]@{ Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\InputPersonalization\TrainedDataStore"; Name = "HarvestContacts"; Expected = 0; Description = "Disable Contact Harvesting" }
)

Write-Host "--- WinHome Privacy Preset Verification (Robust) ---" -ForegroundColor Cyan
Write-Host "Checking 8 Registry Keys..."

$allPassed = $true
foreach ($t in $tweaks) {
    Write-Host "[$($t.Description)]" -ForegroundColor Gray
    Write-Host "  Registry Path: $($t.Path)"
    
    if (Test-Path $t.Path) {
        $val = Get-ItemProperty -Path $t.Path -Name $t.Name -ErrorAction SilentlyContinue
        if ($null -ne $val -and $val.$($t.Name) -eq $t.Expected) {
            Write-Host "  Result: [PASS] (Value: $($val.$($t.Name)))" -ForegroundColor Green
        } else {
            $currentValue = if ($null -eq $val) { "Value Missing" } else { $val.$($t.Name) }
            Write-Host "  Result: [FAIL] (Current: $currentValue, Expected: $($t.Expected))" -ForegroundColor Red
            $allPassed = $false
        }
    } else {
        Write-Host "  Result: [FAIL] (Registry Path does not exist)" -ForegroundColor Red
        $allPassed = $false
    }
    Write-Host ""
}

if ($allPassed) {
    Write-Host "✅ VERIFICATION SUCCESSFUL!" -ForegroundColor Green
} else {
    Write-Host "❌ VERIFICATION FAILED!" -ForegroundColor Red
}

@DotDev262

Copy link
Copy Markdown
Owner

Hi @Prateek2007-cmd! Thanks for the updates. The implementation looks clean and correct, but there are two quick tasks to complete before merging:

  1. Lint/Format Check: The CI is currently failing on formatting. Please run dotnet format on your local branch to fix whitespace/formatting issues in tests/WinHome.Tests/RegistryServiceTests.cs (lines 55 and 56) and push the update.
  2. Verification Screenshot: Please run the robust PowerShell verification script provided by the owner (@DotDev262) in a VM and post a screenshot of the successful output to verify the changes.

Once these are resolved, we'll be ready to merge!

@DotDev262 DotDev262 added level:beginner Beginner level task type:feature New feature labels May 20, 2026
@DotDev262

Copy link
Copy Markdown
Owner

Please update your branch to the latest main branch to ensure compatibility with recent changes. You can do this by rebasing or merging main into your feature branch.

@DotDev262

Copy link
Copy Markdown
Owner

Thanks for the contribution! Before we can merge, please:\n\n1. Update your branch: Rebase or merge the latest main to resolve conflicts.\n2. Fix formatting: Run to resolve lint/format issues (specifically in lines 55-56 as indicated by CI).\n3. Verification: Once the above are done, we can proceed with the VM verification as discussed.\n\nLet me know when you've updated the branch and I'll re-check mergeability.

@DotDev262

Copy link
Copy Markdown
Owner

Hi @Prateek2007-cmd! Thanks for your contribution to add the privacy security preset.

Before we can merge this PR, there are a few items to address:

  1. Merge Conflicts: The PR currently has merge conflicts with the main branch (specifically in ). Please rebase your branch onto the latest main to resolve these conflicts.

  2. Code Formatting: As noted in previous comments, please run to fix any lint/formatting issues, particularly in the test files.

  3. Verification: Once the above are resolved, we can proceed with the final verification steps discussed.

Could you please:

  • Fetch the latest main:
  • Rebase your branch: Auto-merging src/Services/System/SystemSettingsService.cs
    Auto-merging tests/WinHome.Tests/SystemSettingsServiceTests.cs
    CONFLICT (content): Merge conflict in tests/WinHome.Tests/SystemSettingsServiceTests.cs
  • Resolve any conflicts (particularly in the test file)
  • Push the updated branch:

Let me know when you've updated the branch and I'll re-check the merge status!

@DotDev262

Copy link
Copy Markdown
Owner

Closing this PR as superseded by #93, which was already merged into main. Every change here (privacy preset, IRegistryKey? return type, JsonElement handling, subkey null-safety, missing-key test) is already in main via PR #93. Thank you for the contribution!

@DotDev262

Copy link
Copy Markdown
Owner

Superseded by PR #93

@DotDev262 DotDev262 closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSOC points (Required) GSSOC GirlScript Summer of Code 2026 level:beginner Beginner level task type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Settings] Add a Privacy Preset

2 participants