Skip to content
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

Create trust boundary doc Fixes #45340 #45666

Merged
merged 6 commits into from
Mar 26, 2025

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Jan 1, 2025

Fixes #45340

I wasn't really sure what other information to include, so please opine on what's missing 🙂

I was also unsure what I should label truly 'safe', as we can't even say that if everything is trusted, then everything will be ok...because you can very easily compromise your own machine.

And of course, I need to fix the links eventually.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Jan 1, 2025
@Forgind Forgind marked this pull request as ready for review February 6, 2025 19:39
# Types of Threats

## Untrusted Source Code
You should never build or run code from an untrusted source without employing mitigating factors like those described [here](https://github.com/dotnet/sdk/blob/main/documentation/general/ExecutingCustomerCode.md). Additionally, some SDK commands will automatically find code or code-adjacent files in the current directory or any parent directory up to the file system root. Files that may affect a build or other command if found include but are not limited to a Directory.Build.props, global.json, NuGet.config, or dotnet-tools.json. You should also check your home folder as well as environment variables that may point to other locations the SDK will search to find code or configuration files.
Copy link
Contributor

Choose a reason for hiding this comment

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

MSBuild.rsp too, according to dotnet/msbuild#11472.

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

This looks well-written to me. It would be ideal to get an approval from the security folks as there are likely things I haven't thought about which may be appropriate for this file but off the top of my head, I couldn't think of any and this is more useful to document than not regardless.

You should never build or run code from an untrusted source without employing mitigating factors like those described [here](https://github.com/dotnet/sdk/blob/main/documentation/general/ExecutingCustomerCode.md). Additionally, some SDK commands will automatically find code or code-adjacent files in the current directory, project directory, or executable directory, or any parent directory of any of those up to the file system root. Files that may affect a build or other command if found include but are not limited to a Directory.Build.props, global.json, NuGet.config, or dotnet-tools.json. You should also check your home folder as well as environment variables that may point to other locations the SDK will search to find code or configuration files.

## Untrusted Locations
Some folders often store untrusted files. (The Downloads folder is a fairly straightforward example of that.) Some commands look "next to" the project, solution, or other code file being worked with in the directory. It is generally recommended to avoid running dotnet commands from within any directory that contains any files you do not trust.

Choose a reason for hiding this comment

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

You can be more forceful,

It is generally recommended to avoid running dotnet commands from within any directory that contains any files you do not trust.

becomes

Do notrunning dotnet commands from within any directory that contains any files you do not trust.

Copy link
Member

@MiYanni MiYanni left a comment

Choose a reason for hiding this comment

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

This is a great starter for this kind of document. LGTM

# Types of Threats

## Untrusted Source Code
You should never build or run code from an untrusted source without employing mitigating factors like those described [here](https://github.com/dotnet/sdk/blob/main/documentation/general/ExecutingCustomerCode.md). Additionally, some SDK commands will automatically find code or code-adjacent files in the current directory, project directory, executable directory, or any parent directory of any of those up to the file system root. Files that may affect a build or other command if found include but are not limited to a Directory.Build.props, global.json, NuGet.config, or dotnet-tools.json. You should also check your home folder as well as environment variables that may point to other locations the SDK will search to find code or configuration files.
Copy link
Member

Choose a reason for hiding this comment

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

nit: Change the link to [here](general/ExecutingCustomerCode.md). This doc itself lives in the same repo to the doc you're linking to, so always use a relative link. It makes a difference as then this doc always links to its sibling doc with the same branch. Plus, main isn't always guaranteed to exist, as that similar situation happened during the switch from master to main. StackOverflow on linking here.

You should never build or run code from an untrusted source without employing mitigating factors like those described [here](https://github.com/dotnet/sdk/blob/main/documentation/general/ExecutingCustomerCode.md). Additionally, some SDK commands will automatically find code or code-adjacent files in the current directory, project directory, executable directory, or any parent directory of any of those up to the file system root. Files that may affect a build or other command if found include but are not limited to a Directory.Build.props, global.json, NuGet.config, or dotnet-tools.json. You should also check your home folder as well as environment variables that may point to other locations the SDK will search to find code or configuration files.

## Untrusted Locations
Some folders often store untrusted files. (The Downloads folder is a fairly straightforward example of that.) Some commands look "next to" the project, solution, or other code file being worked with in the directory. Do not run dotnet commands from within any directory that contains any files you do not trust.
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe change Dot not run dotnet commands to Do not run dotnet CLI commands?

@Forgind Forgind merged commit b3f4a20 into dotnet:main Mar 26, 2025
8 checks passed
@Forgind Forgind deleted the document-security-boundary branch March 26, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create documentation about trust boundaries of the .NET SDK and how to use it securely
5 participants