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

taint untrusted data #269

Open
1 of 5 tasks
frasertweedale opened this issue Mar 27, 2019 · 5 comments
Open
1 of 5 tasks

taint untrusted data #269

frasertweedale opened this issue Mar 27, 2019 · 5 comments
Assignees
Labels

Comments

@frasertweedale
Copy link
Member

frasertweedale commented Mar 27, 2019

Purebred handles several kinds of untrusted data:

  • emails, and parts thereof after parsing
  • files provided by the user (attachments, composed email content)
  • process output (especially when subprocesses operate on untrusted data!)

We should use types to demarcate these untrusted data and force (or at least "strongly encourage") the programmer to sanitise the data properly before handling it. This is especially relevant when:

  • sending data to the terminal for display
  • logging data (not that we currently do any logging)
  • deciding a file name based on untrusted data
  • probably some other situations?

The specific deliverables are grouped by the kinds of data we want to taint:

  • output from subprocesses
  • mail bodies
  • files loaded by the user (mail bodies may cover this)
  • mail header values
  • tags (and other direct data from libnotmuch)
@frasertweedale frasertweedale self-assigned this Mar 27, 2019
frasertweedale added a commit that referenced this issue Mar 27, 2019
This commit adds the Purebred.Types.IFC module for information flow
control (IFC) types and functions.  We begin with a trivial taint
mechanism.  A single aspect of the implementation - tryRunProcess -
is updated to use it, for demonstration and review purposes.

Part of: #269
@frasertweedale
Copy link
Member Author

@romanofski POC commit: 7e2b74c. LMK what you think. It doesn't have to be a big bang, we can do it progressively.

@romanofski
Copy link
Member

Yep I like this very much. So the deal is basically that we use Tainted to express the fact that the data could be malicious or "dirty" and needs to be "cleaned" before displaying. (I think that's exactly what you wrote in the description, but I wanted to express it with my words in order to have it understood).

@frasertweedale
Copy link
Member Author

Cool, so I'll push forward with this on the subprocess side and make that the first deliverable. Afterwards I'll turn focus to taint on mail bodies / parts.

frasertweedale added a commit that referenced this issue Mar 29, 2019
Taint sendmail stderr.  Also re-export some typed-process
ProcessConfig-related types and functions from
Purebred.System.Process.  This is a move to avoid importing
System.Process.Typed anywhere in purebred, except this one module,
ensuring that all the "run process" functions that are available
taint the process output.

Part of: #269
frasertweedale added a commit that referenced this issue Mar 29, 2019
Create tainting version of readProcess and update
Storage.Notmuch.getDatabasePath to use it.

Part of: #269
frasertweedale added a commit that referenced this issue Mar 29, 2019
Re-export 'shell' from Purebred.System.Process so that we can avoid
directly importing System.Process.Typed anywhere (except the
aforementioned module).  We want to avoid using typed-process
directly; instead we want to ensure we use our own variants that
taint the process output.

Part of: #269
romanofski pushed a commit that referenced this issue Mar 29, 2019
This commit adds the Purebred.Types.IFC module for information flow
control (IFC) types and functions.  We begin with a trivial taint
mechanism.  A single aspect of the implementation - tryRunProcess -
is updated to use it, for demonstration and review purposes.

Part of: #269
romanofski pushed a commit that referenced this issue Mar 29, 2019
Taint sendmail stderr.  Also re-export some typed-process
ProcessConfig-related types and functions from
Purebred.System.Process.  This is a move to avoid importing
System.Process.Typed anywhere in purebred, except this one module,
ensuring that all the "run process" functions that are available
taint the process output.

Part of: #269
romanofski pushed a commit that referenced this issue Mar 29, 2019
Create tainting version of readProcess and update
Storage.Notmuch.getDatabasePath to use it.

Part of: #269
romanofski pushed a commit that referenced this issue Mar 29, 2019
Re-export 'shell' from Purebred.System.Process so that we can avoid
directly importing System.Process.Typed anywhere (except the
aforementioned module).  We want to avoid using typed-process
directly; instead we want to ensure we use our own variants that
taint the process output.

Part of: #269
romanofski pushed a commit that referenced this issue Mar 29, 2019
@romanofski romanofski added feature and removed feature labels Apr 3, 2019
@romanofski romanofski added this to the Future Feature milestone Jun 7, 2019
@romanofski
Copy link
Member

Btw @frasertweedale was wondering whether is might use the plugin system too or should we just apply what we already have?

@frasertweedale
Copy link
Member Author

No, this is built-in behaviour.

It is a good question whether data from plugins should be trusted or not. In general, because the user explicitly enables the plugin, there is no need to taint data from plugins. But perhaps there will be a use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants