π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Sign Auth Windows payload binaries
Neeraj Gupta55a57c6c570e
diff --git a/.github/workflows/auth-beta-release.yml b/.github/workflows/auth-beta-release.ymlindex 018c3dc98e..b491c479a0 100644--- a/.github/workflows/auth-beta-release.yml+++ b/.github/workflows/auth-beta-release.yml@@ -267,21 +267,48 @@ jobs:- name: Create artifacts directoryrun: mkdir artifacts- - name: Build Windows installer+ - name: Build Windows releaserun: |flutter config --enable-windows-desktop- dart pub global activate --source git https://github.com/ente-io/fastforgefork --git-ref develop --git-path packages/fastforgechoco install innosetup -y- fastforge.bat package --platform=windows --targets=exe --skip-clean- shopt -s globstar- mv dist/**/*-windows-setup.exe artifacts/ente-auth-v${{ env.VERSION_NAME }}-beta-installer.exe+ flutter build windows --releaseshell: bash- - name: Retain Windows EXE and DLLs- run: cp -r build/windows/x64/runner/Release ente-auth-v${{ env.VERSION_NAME }}-beta-windows- shell: bash+ - name: Verify Windows PE allowlist+ run: |+ & ./scripts/verify_windows_pe_allowlist.ps1 `+ -PayloadDir "build/windows/x64/runner/Release" `+ -AllowlistPath "windows/signing/allowed-pe-files.txt"+ shell: pwsh- - name: Sign files with Trusted Signing+ - name: Sign Windows payload with Trusted Signing+ uses: azure/trusted-signing-action@v0+ with:+ azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}+ azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}+ azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}+ endpoint: ${{ secrets.AZURE_ENDPOINT }}+ trusted-signing-account-name: ${{ secrets.AZURE_CODE_SIGNING_NAME }}+ certificate-profile-name: ${{ secrets.AZURE_CERT_PROFILE_NAME }}+ files-folder: ${{ github.workspace }}/mobile/apps/auth/build/windows/x64/runner/Release+ files-folder-filter: exe,dll+ files-folder-recurse: true+ file-digest: SHA256+ timestamp-rfc3161: http://timestamp.acs.microsoft.com+ timestamp-digest: SHA256++ - name: Verify signed Windows payload+ run: ./scripts/verify_windows_authenticode.ps1 -Path "build/windows/x64/runner/Release"+ shell: pwsh++ - name: Build Windows installer+ run: |+ & ./scripts/build_windows_installer.ps1 `+ -SourceDir "build/windows/x64/runner/Release" `+ -InstallerPath "artifacts/ente-auth-v${{ env.VERSION_NAME }}-beta-installer.exe"+ shell: pwsh++ - name: Sign Windows installer with Trusted Signinguses: azure/trusted-signing-action@v0with:azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}@@ -292,15 +319,29 @@ jobs:certificate-profile-name: ${{ secrets.AZURE_CERT_PROFILE_NAME }}files: |${{ github.workspace }}/mobile/apps/auth/artifacts/ente-auth-v${{ env.VERSION_NAME }}-beta-installer.exe- ${{ github.workspace }}/mobile/apps/auth/ente-auth-v${{ env.VERSION_NAME }}-beta-windows/auth.exefile-digest: SHA256timestamp-rfc3161: http://timestamp.acs.microsoft.comtimestamp-digest: SHA256+ - name: Verify signed Windows installer+ run: ./scripts/verify_windows_authenticode.ps1 -Path "artifacts/ente-auth-v${{ env.VERSION_NAME }}-beta-installer.exe"+ shell: pwsh++ - name: Retain signed Windows EXE and DLLs+ run: Copy-Item -Recurse -Force "build/windows/x64/runner/Release" "ente-auth-v${{ env.VERSION_NAME }}-beta-windows"+ shell: pwsh- name: Zip Windows EXE and DLLs- run: tar.exe -a -c -f artifacts/ente-auth-v${{ env.VERSION_NAME }}-beta-windows.zip ente-auth-v${{ env.VERSION_NAME }}-beta-windows- shell: bash+ shell: pwsh+ run: |+ $zipPath = "artifacts/ente-auth-v${{ env.VERSION_NAME }}-beta-windows.zip"+ Compress-Archive `+ -Path "ente-auth-v${{ env.VERSION_NAME }}-beta-windows" `+ -DestinationPath $zipPath `+ -Force+ Add-Type -AssemblyName System.IO.Compression.FileSystem+ $zip = [System.IO.Compression.ZipFile]::OpenRead((Resolve-Path $zipPath))+ $zip.Dispose()- name: Generate checksumsrun: sha256sum artifacts/ente-auth-* > artifacts/sha256sum-windowsdiff --git a/.github/workflows/auth-release.yml b/.github/workflows/auth-release.ymlindex 0f73713800..0878d2c83a 100644--- a/.github/workflows/auth-release.yml+++ b/.github/workflows/auth-release.yml@@ -211,21 +211,48 @@ jobs:- name: Create artifacts directoryrun: mkdir artifacts- - name: Build Windows installer+ - name: Build Windows releaserun: |flutter config --enable-windows-desktop- dart pub global activate --source git https://github.com/ente-io/fastforgefork --git-ref develop --git-path packages/fastforgechoco install innosetup -y- fastforge.bat package --platform=windows --targets=exe --skip-clean- shopt -s globstar- mv dist/**/*-windows-setup.exe artifacts/ente-${{ github.ref_name }}-installer.exe+ flutter build windows --releaseshell: bash- - name: Retain Windows EXE and DLLs- run: cp -r build/windows/x64/runner/Release ente-${{ github.ref_name }}-windows- shell: bash+ - name: Verify Windows PE allowlist+ run: |+ & ./scripts/verify_windows_pe_allowlist.ps1 `+ -PayloadDir "build/windows/x64/runner/Release" `+ -AllowlistPath "windows/signing/allowed-pe-files.txt"+ shell: pwsh++ - name: Sign Windows payload with Trusted Signing+ uses: azure/trusted-signing-action@v0+ with:+ azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}+ azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}+ azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}+ endpoint: ${{ secrets.AZURE_ENDPOINT }}+ trusted-signing-account-name: ${{ secrets.AZURE_CODE_SIGNING_NAME }}+ certificate-profile-name: ${{ secrets.AZURE_CERT_PROFILE_NAME }}+ files-folder: ${{ github.workspace }}/mobile/apps/auth/build/windows/x64/runner/Release+ files-folder-filter: exe,dll+ files-folder-recurse: true+ file-digest: SHA256+ timestamp-rfc3161: http://timestamp.acs.microsoft.com+ timestamp-digest: SHA256++ - name: Verify signed Windows payload+ run: ./scripts/verify_windows_authenticode.ps1 -Path "build/windows/x64/runner/Release"+ shell: pwsh- - name: Sign files with Trusted Signing+ - name: Build Windows installer+ run: |+ & ./scripts/build_windows_installer.ps1 `+ -SourceDir "build/windows/x64/runner/Release" `+ -InstallerPath "artifacts/ente-${{ github.ref_name }}-installer.exe"+ shell: pwsh++ - name: Sign Windows installer with Trusted Signinguses: azure/trusted-signing-action@v0with:azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}@@ -236,15 +263,29 @@ jobs:certificate-profile-name: ${{ secrets.AZURE_CERT_PROFILE_NAME }}files: |${{ github.workspace }}/mobile/apps/auth/artifacts/ente-${{ github.ref_name }}-installer.exe- ${{ github.workspace }}/mobile/apps/auth/ente-${{ github.ref_name }}-windows/auth.exefile-digest: SHA256timestamp-rfc3161: http://timestamp.acs.microsoft.com- timestamp-digest: SHA256+ timestamp-digest: SHA256++ - name: Verify signed Windows installer+ run: ./scripts/verify_windows_authenticode.ps1 -Path "artifacts/ente-${{ github.ref_name }}-installer.exe"+ shell: pwsh+ - name: Retain signed Windows EXE and DLLs+ run: Copy-Item -Recurse -Force "build/windows/x64/runner/Release" "ente-${{ github.ref_name }}-windows"+ shell: pwsh- name: Zip Windows EXE and DLLs- run: tar.exe -a -c -f artifacts/ente-${{ github.ref_name }}-windows.zip ente-${{ github.ref_name }}-windows- shell: bash+ shell: pwsh+ run: |+ $zipPath = "artifacts/ente-${{ github.ref_name }}-windows.zip"+ Compress-Archive `+ -Path "ente-${{ github.ref_name }}-windows" `+ -DestinationPath $zipPath `+ -Force+ Add-Type -AssemblyName System.IO.Compression.FileSystem+ $zip = [System.IO.Compression.ZipFile]::OpenRead((Resolve-Path $zipPath))+ $zip.Dispose()- name: Generate checksumsrun: sha256sum artifacts/ente-* > artifacts/sha256sum-windowsdiff --git a/mobile/apps/auth/scripts/build_windows_installer.ps1 b/mobile/apps/auth/scripts/build_windows_installer.ps1new file mode 100644index 0000000000..d5a8d6e8bd--- /dev/null+++ b/mobile/apps/auth/scripts/build_windows_installer.ps1@@ -0,0 +1,100 @@+param(+ [Parameter(Mandatory = $true)]+ [string] $SourceDir,++ [Parameter(Mandatory = $true)]+ [string] $InstallerPath+)++$ErrorActionPreference = "Stop"++if (-not (Test-Path -LiteralPath $SourceDir -PathType Container)) {+ throw "Source directory not found: $SourceDir"+}++$sourceRoot = (Resolve-Path -LiteralPath $SourceDir).Path+$installerFullPath = [System.IO.Path]::GetFullPath($InstallerPath)+$installerDir = Split-Path -Parent $installerFullPath+$outputBaseFilename = [System.IO.Path]::GetFileNameWithoutExtension($installerFullPath)++New-Item -ItemType Directory -Force -Path $installerDir | Out-Null+Remove-Item -LiteralPath $installerFullPath -Force -ErrorAction SilentlyContinue++$pubspecPath = Join-Path $PSScriptRoot "..\pubspec.yaml"+$versionLine = Select-String -LiteralPath $pubspecPath -Pattern "^version:\s*(\S+)" | Select-Object -First 1+if (-not $versionLine) {+ throw "Could not read version from $pubspecPath"+}+$appVersion = $versionLine.Matches[0].Groups[1].Value++$iconPath = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\assets\icons\auth-icon.ico"))+$sourceGlob = (Join-Path $sourceRoot "*").Replace("/", "\")+$escapedInstallerDir = $installerDir.Replace("/", "\")+$issPath = Join-Path ([System.IO.Path]::GetTempPath()) "ente-auth-installer.iss"++$iss = @"+[Setup]+AppId=9E5F0C93-96A3-4DA9-AE52-1AA6339851FC+AppVersion=$appVersion+AppName=Ente Auth+AppPublisher=ente.io+AppPublisherURL=https://github.com/ente-io/ente+AppSupportURL=https://github.com/ente-io/ente+AppUpdatesURL=https://github.com/ente-io/ente+DefaultDirName={autopf}\Ente Auth+DisableProgramGroupPage=yes+OutputDir=$escapedInstallerDir+OutputBaseFilename=$outputBaseFilename+Compression=zip+SolidCompression=yes+SetupIconFile=$iconPath+WizardStyle=modern+;PrivilegesRequired=none+PrivilegesRequiredOverridesAllowed=dialog+ArchitecturesAllowed=x64compatible+ArchitecturesInstallIn64BitMode=x64compatible+UninstallDisplayIcon={app}\auth.exe++[Languages]+Name: "english"; MessagesFile: "compiler:Default.isl"++[Tasks]+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked+Name: "launchAtStartup"; Description: "{cm:AutoStartProgram,Ente Auth}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked++[Files]+Source: "$sourceGlob"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs+; NOTE: Don't use "Flags: ignoreversion" on any shared system files++[Icons]+Name: "{autoprograms}\Ente Auth"; Filename: "{app}\auth.exe"+Name: "{autodesktop}\Ente Auth"; Filename: "{app}\auth.exe"; Tasks: desktopicon+Name: "{userstartup}\Ente Auth"; Filename: "{app}\auth.exe"; WorkingDir: "{app}"; Tasks: launchAtStartup++[Run]+Filename: "{app}\auth.exe"; Description: "{cm:LaunchProgram,Ente Auth}"; Flags: runascurrentuser nowait postinstall skipifsilent+"@++$utf8WithBom = [System.Text.UTF8Encoding]::new($true)+[System.IO.File]::WriteAllText($issPath, $iss, $utf8WithBom)++$iscc = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"+if (-not (Test-Path -LiteralPath $iscc -PathType Leaf)) {+ $isccCommand = Get-Command "ISCC.exe" -ErrorAction SilentlyContinue+ if (-not $isccCommand) {+ throw "Inno Setup compiler not found. Install Inno Setup 6 before running this script."+ }+ $iscc = $isccCommand.Source+}++& $iscc $issPath+if ($LASTEXITCODE -ne 0) {+ throw "Inno Setup failed with exit code $LASTEXITCODE"+}++if (-not (Test-Path -LiteralPath $installerFullPath -PathType Leaf)) {+ throw "Expected installer was not created: $installerFullPath"+}++Remove-Item -LiteralPath $issPath -Force -ErrorAction SilentlyContinue+Write-Host "Created installer: $installerFullPath"diff --git a/mobile/apps/auth/scripts/verify_windows_authenticode.ps1 b/mobile/apps/auth/scripts/verify_windows_authenticode.ps1new file mode 100644index 0000000000..6776b02ff0--- /dev/null+++ b/mobile/apps/auth/scripts/verify_windows_authenticode.ps1@@ -0,0 +1,43 @@+param(+ [Parameter(Mandatory = $true)]+ [string] $Path,++ [string[]] $Include = @("*.exe", "*.dll")+)++$ErrorActionPreference = "Stop"++if (-not (Test-Path -LiteralPath $Path)) {+ throw "Path not found: $Path"+}++$item = Get-Item -LiteralPath $Path++if ($item.PSIsContainer) {+ $files = Get-ChildItem -LiteralPath $item.FullName -Recurse -File -Include $Include | Sort-Object FullName+} else {+ $files = @($item)+}++if (-not $files) {+ Write-Error "No files found to verify under: $Path"+}++$badSignatures = foreach ($file in $files) {+ $signature = Get-AuthenticodeSignature -FilePath $file.FullName+ if ($signature.Status -ne "Valid") {+ [PSCustomObject]@{+ Path = $file.FullName+ Status = $signature.Status+ StatusMessage = $signature.StatusMessage+ }+ }+}++if ($badSignatures) {+ Write-Host "Invalid Authenticode signatures:"+ $badSignatures | Format-Table -AutoSize | Out-String | Write-Host+ exit 1+}++Write-Host "Verified Authenticode signatures for $($files.Count) file(s)."diff --git a/mobile/apps/auth/scripts/verify_windows_pe_allowlist.ps1 b/mobile/apps/auth/scripts/verify_windows_pe_allowlist.ps1new file mode 100644index 0000000000..a10ae67363--- /dev/null+++ b/mobile/apps/auth/scripts/verify_windows_pe_allowlist.ps1@@ -0,0 +1,84 @@+param(+ [Parameter(Mandatory = $true)]+ [string] $PayloadDir,++ [Parameter(Mandatory = $true)]+ [string] $AllowlistPath+)++$ErrorActionPreference = "Stop"++if (-not (Test-Path -LiteralPath $PayloadDir -PathType Container)) {+ throw "Payload directory not found: $PayloadDir"+}++if (-not (Test-Path -LiteralPath $AllowlistPath -PathType Leaf)) {+ throw "Allowlist not found: $AllowlistPath"+}++$payloadRoot = (Resolve-Path -LiteralPath $PayloadDir).Path+$allowlist = Get-Content -LiteralPath $AllowlistPath |+ ForEach-Object { $_.Trim() } |+ Where-Object { $_ -and -not $_.StartsWith("#") } |+ ForEach-Object { $_.Replace("\", "/") }++$duplicateEntries = $allowlist |+ Group-Object |+ Where-Object { $_.Count -gt 1 } |+ ForEach-Object { $_.Name }++if ($duplicateEntries) {+ Write-Host "Duplicate entries in ${AllowlistPath}:"+ $duplicateEntries | ForEach-Object { Write-Host " $_" }+ exit 1+}++$allowed = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)+foreach ($entry in $allowlist) {+ [void] $allowed.Add($entry)+}++$payloadFiles = Get-ChildItem -LiteralPath $payloadRoot -Recurse -File -Include *.exe, *.dll |+ ForEach-Object {+ [PSCustomObject]@{+ File = $_+ RelativePath = [System.IO.Path]::GetRelativePath($payloadRoot, $_.FullName).Replace("\", "/")+ }+ } |+ Sort-Object RelativePath++if (-not $payloadFiles) {+ Write-Error "No Windows PE files found in payload directory: $payloadRoot"+}++$actual = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)+foreach ($file in $payloadFiles) {+ [void] $actual.Add($file.RelativePath)+}++$unexpected = $payloadFiles |+ Where-Object { -not $allowed.Contains($_.RelativePath) } |+ ForEach-Object { $_.RelativePath }++$missing = $allowlist |+ Where-Object { -not $actual.Contains($_) } |+ Sort-Object++Write-Host "Windows PE files found in payload:"+$payloadFiles | ForEach-Object { Write-Host " $($_.RelativePath)" }++if ($unexpected -or $missing) {+ if ($unexpected) {+ Write-Host "Unexpected Windows PE files. Review each file before adding it to ${AllowlistPath}:"+ $unexpected | ForEach-Object { Write-Host " $_" }+ }++ if ($missing) {+ Write-Host "Allowlisted Windows PE files missing from payload. Remove only after confirming the binary is no longer shipped:"+ $missing | ForEach-Object { Write-Host " $_" }+ }++ exit 1+}++Write-Host "Windows PE allowlist matched $($payloadFiles.Count) file(s)."diff --git a/mobile/apps/auth/windows/signing/allowed-pe-files.txt b/mobile/apps/auth/windows/signing/allowed-pe-files.txtnew file mode 100644index 0000000000..515c0bdf25--- /dev/null+++ b/mobile/apps/auth/windows/signing/allowed-pe-files.txt@@ -0,0 +1,19 @@+app_links_plugin.dll+auth.exe+connectivity_plus_plugin.dll+dartjni.dll+file_saver_plugin.dll+flutter_local_authentication_plugin.dll+flutter_secure_storage_windows_plugin.dll+flutter_windows.dll+libsodium.dll+local_auth_windows_plugin.dll+screen_retriever_windows_plugin.dll+sentry.dll+share_plus_plugin.dll+sodium_libs_plugin.dll+sqlite3.dll+sqlite3_flutter_libs_plugin.dll+tray_manager_plugin.dll+url_launcher_windows_plugin.dll+window_manager_plugin.dll