Skip to content

Prevent DLL hijacking by setting default DLL directories on initialization #4207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ansxuman
Copy link

@ansxuman ansxuman commented Apr 9, 2025

Description

This PR fixes a DLL hijacking vulnerability identified during a VAPT assessment. When the application tries to load certain DLLs from the application directory instead of the system directories, it creates a potential security risk where an attacker could place malicious DLLs in the application directory.

The issue affects several DLLs including:

  • uxtheme.dll
  • WindowsCodecs.dll
  • dwmapi.dll
  • PROPSYS.dll
  • CRYPTBASE.dll
  • Secur32.dll
  • SSPICLI.DLL
  • MLANG.dll
  • WININET.dll

While most DLLs can be fixed by adding windows.SetDefaultDllDirectories(windows.LOAD_LIBRARY_SEARCH_SYSTEM32) in application code, the uxtheme.dll is loaded by the Wails before application initialization. This PR addresses this issue by adding the secure DLL loading directive at the framework level.

Additional Background Information

Our security team recently discovered a DLL hijacking vulnerability in our application. After digging into it, I found that this is actually a common issue in Go applications - there's even a similar bug report in the Go repository (golang/go#64411).
Here's what's happening: When Windows looks for DLLs, it first checks the application directory before checking system directories. This creates a security risk where someone could drop malicious versions of these DLLs into our application folder.
I initially tried fixing this in our code by adding windows.SetDefaultDllDirectories(windows.LOAD_LIBRARY_SEARCH_SYSTEM32), which tells Windows to prioritize loading DLLs from the System32 directory. This worked for most DLLs, but not for uxtheme.dll, it loaded by Wails before application initialization, so our fix never gets a chance to take effect.It's an important security improvement that protects applications from a potentially serious attack vector where bad actors could execute arbitrary code through fake DLLs.

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Steps to Reproduce

  1. Create a basic Wails application
  2. Build the application for Windows
  3. Run Process Monitor while launching the application and Filter the PATH to <Application Directory>\uxtheme.dll and observe

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

PS C:\Users\DELL\wails\v2\cmd\wails> .\wails.exe doctor       

# Wails
Version  | v2.10.1
Revision | 194b0586ba63b3003bb6f5c3b5bc48f8c84720fc
Modified | true


# System
┌─────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Windows 10 Pro                                                       |
| Version      | 2009 (Build: 19045)                                                  |
| ID           | 22H2                                                                 |
| Branding     | Windows 10 Pro                                                       |
| Go Version   | go1.23.0                                                             |
| Platform     | windows                                                              |
| Architecture | amd64                                                                |
| CPU          | Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz                             |
| GPU          | Intel(R) HD Graphics 620 (Intel Corporation) - Driver: 31.0.101.2127 |
| Memory       | 16GB                                                                 |
└─────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version       |
| WebView2   | N/A          | Installed | 134.0.3124.93 |
| Nodejs     | N/A          | Installed | 22.14.0       |
| npm        | N/A          | Installed | 10.9.2        |
| *upx       | N/A          | Available |               |
| *nsis      | N/A          | Available |               |
|                                                       |
└─────────────── * - Optional Dependency ───────────────┘

# Diagnosis
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Introduced a new option for Windows users to control DLL search paths, enhancing the application's configurability.
    • Expanded DLL loading settings with advanced controls, allowing for more detailed management of how DLL files are located on Windows platforms.
  • Improvements
    • Updated function visibility for improved accessibility and initialization within the application.

Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

## Walkthrough
This pull request introduces a new `DLLSearchPaths` option for Windows systems, allowing users to specify DLL search paths. It adds a changelog entry, updates the Windows frontend to conditionally call a Windows API function based on the new option, and extends the Windows options package with additional constants and a new field. The changes enhance configurability regarding DLL file locations without impacting existing functionality.

## Changes

| File(s)                                     | Change Summary                                                                                                                                          |
|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| website/src/.../changelog.mdx               | Added a new changelog entry for the DLLSearchPaths option to control DLL search paths on Windows.                                                       |
| v2/internal/frontend/desktop/windows/frontend.go, v2/pkg/options/windows/windows.go | Introduced DLLSearchPaths support by adding a new import from the Windows package, a conditional call to SetDefaultDllDirectories in NewFrontend, and new constants and a field in the Options struct to manage DLL search configurations. |
| v2/internal/frontend/desktop/windows/winc/w32/uxtheme.go, v2/internal/platform/win32/consts.go | Changed function names from `init` to `Init` in both files to make them exported, allowing access from other packages while keeping internal logic unchanged. |

## Sequence Diagram(s)
```mermaid
sequenceDiagram
    participant App as Application
    participant Options as AppOptions.Windows
    participant WinPkg as Windows Package (w)

    App->>Options: Check if Windows options exist and DLLSearchPaths > 0
    alt Valid DLLSearchPaths
      App->>WinPkg: Call SetDefaultDllDirectories(DLLSearchPaths)
    else Missing/Zero Value
      App-->>App: Skip DLL configuration
    end

Suggested reviewers

  • leaanthony

Poem

I'm a rabbit in code,
Hopping through DLLs with joy untold,
New search paths in Windows gleam bright,
Constants and flags guide them just right,
The changelog sings of updates so neat,
With every hop, my circuits skip a beat! 🐰✨


<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡💬 Agentic Chat (Pro Plan, General Availability)</summary>
> 
> - We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 72316d61928ea1c83d80cb387a5fb9acf18b19e1 and 9415e82d1338114b2a0d5346993bfaf0b0f8a0dd.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `v2/internal/frontend/desktop/windows/frontend.go` (2 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* v2/internal/frontend/desktop/windows/frontend.go

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIrfykMUIARABkUyAQhNAYAa3gMIkg5exJccQLIJQAzNG9ktMr4fzF8Cnhpfix89Xg0L3gAL2p4fAxo9Fpaf0REDrQShmw23HkJb3IqNX6VlCVE+Cr2+lol/ML5gDV15S31eQBBGelENkT0DHorMlKqcVGYEJnSAACgu9ys0AAlOgnjNXpoYLAPGsvBsVPBtvJnEgOgJRLVZmEkehuNx+gxhv8vPg0LRkAxKLhtFhUilkFUKCwULhkPgAO5YWhNUQEFxFEhVVoeBhI3JAxCyRA0ZiNZqi9qIAA0kD5CBlCm89D61L573QZWyOUoYXwPC82Q8zD68AYI2wyFZyHyRI8aFJ5MpWElXiUfEw9BIAA9RHhfRQ1LgqGKmEoNG5iWgqlURVFPSgMAwvNglFxsJHcEi2BpaD5tQB1fK0fmIADCilEiGrtcqfKd3HgXa82tsAHkrABlACa48H2pbNknEIAQvdxwBRWeQccxigAZgATJvx+OrABJFspU8aVnagCyKXuADkAOKb8OQOunx9ftfQQcaREPF4fBuHwWZ6EOSN8wkfAvCkZBaSFCoKw8I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4HSP5B7kMNW0/PJymO4DmOWM77WOm3COiPMthNa00O4H5kYBcvehyM8vGN8sPSCsXLCvZE2Oep6MW27ajYl61YLz1aEAOP6nzacB+BoDLbONijFAKGbCbbDY7YGD6uUa4AsSVmIAsTxDtCya0AsTIahAVYutVaMDYz7jZC0BTPYwkDYwACcAAbFMwAKwMAJsZwZzJtZhTO0ApxTO4y0AJtxu4y7hTNVD7jJvJvFtlvbaGCut0BTM8nYzYzJtTMJv7gZxVDYwZwdtyIZwMgMAZztsMCFtxtoC4xxtxsMD7j5u1shsQDKQ5skD7iDtoAdspy4zJu5txtVAMC4wpwCDlsHJxu7gMApwJskA7sCBxsCAJsCC4weAjahvJsJtbvmbTsRtVCbu7hju7jJtoBjvtsvt4ibtxtpxTOZjZB/sZxzv6s9u7jYwJuFvxsztyLYwMAzNRu4wMACClsZxoBZvXvZBdtTMCDxuxuwehtgctskBTP7i0DYyzPRvYwHsRsFvJtzNFsnuHuZi4z3tVAQcFv0DBuussDUzuueveviFQ50AsQ1a1tAA -->

<!-- internal state end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=wailsapp/wails&utm_content=4207):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@leaanthony
Copy link
Member

Thanks for taking the time to open this 🙏

I absolutely see the need for this but the solution will need to be more flexible to accommodate everyone's use cases. Some people ship DLLs with their binaries using NSIS and this will break their apps in a way they can't fix.

Proposal: create a windows specific application setting that lists the set of search paths. Let's call it DLLSearchPaths. If this is blank, we do nothing and default to Go's defaults. If given, then we set them at application startup. This will mean updating most of the win32 package as you've noted.

Thoughts?

@leaanthony
Copy link
Member

Do you think we need to change func init() { in uxtheme.go to func Init() { and call this manually after setting the DLL search paths? Alternatively, you could try lazy loading the DLL but I'm guessing there's a reason this is being loaded differently.

@ansxuman
Copy link
Author

ansxuman commented Apr 12, 2025

Do you think we need to change func init() { in uxtheme.go to func Init() { and call this manually after setting the DLL search paths? Alternatively, you could try lazy loading the DLL but I'm guessing there's a reason this is being loaded differently.

Thanks for highlighting this. I didn’t get a chance to test the new changes as my Windows laptop is having some issues. I would prefer changing func init() to func Init() in both uxtheme.go and consts.go for a minimal impact.

@leaanthony
Copy link
Member

Sounds good. Can you please make sure that the changes work correctly and they don't flicker windows when they start up or anything? That is my only concern with converting the init function.

@ansxuman
Copy link
Author

Sounds good. Can you please make sure that the changes work correctly and they don't flicker windows when they start up or anything? That is my only concern with converting the init function.

Sure i will do proper testing and update you here.

@ansxuman
Copy link
Author

Tested on Windows 10, I did not observe any issues.

@@ -80,7 +80,7 @@ ShouldSystemUseDarkMode = bool () // ordinal 138
SetPreferredAppMode = PreferredAppMode (PreferredAppMode appMode) // ordinal 135, since 18334
IsDarkModeAllowedForApp = bool () // ordinal 139
*/
func init() {
func Init() {
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to call these Init() methods?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the confusion. I misunderstood Go's initialization behavior, thinking capitalization affected execution order of Init() but relized it will behave like very other exported func. Now calling it explicitly after setting the dll path.

Copy link

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