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

GC Heap Compaction should clear the source data #10480

Open
bartonjs opened this issue Jun 8, 2018 · 3 comments
Open

GC Heap Compaction should clear the source data #10480

bartonjs opened this issue Jun 8, 2018 · 3 comments
Assignees
Milestone

Comments

@bartonjs
Copy link
Member

bartonjs commented Jun 8, 2018

During GC heap compaction a copy of data is made. In cases where there was no practical way to pin data (e.g. a returned byte[]) it isn't possible to ensure that the data has been adequately cleared because of the extra copy created compaction.

Having the GC clear the memory on compaction improve the security of applications for which heap dumps and in-memory probes are within their scope of threat, given some guidelines:

  • A secret allocated to a caller is the caller's responsibility to clear (e.g. RSA.Decrypt).
    • Current: Returned objects can't be pinned in a practical manner, API would have to also emit a GCHandle.
  • A secret held by an IDisposable object should be cleared on Dispose, and it is the owner's responsibility to call Dispose (e.g. KeyedHashAlgorithm)
    • Current: existing classes which have byte[] fields would need to use GCHandle and add a finalizer to ensure that the handle got cleared.
  • A temporary copy of a secret must be cleared by the creator/owner (e.g. addition/removal of symmetric encryption padding)

If the GC can guarantee that pinning is no longer required to ensure that Span.Clear() removes the data from the heap then a good amount of defensive pinning can be eliminated from current BCL security code (theoretically reducing heap fragmentation?).

@Maoni0 Maoni0 self-assigned this Apr 18, 2019
@Maoni0
Copy link
Member

Maoni0 commented Jun 25, 2019

I apologize - looks like we'll not be able to fit this one in 3.0 since we had other more urgent items for this release...we'll need to see whether this could possibly fit in the next 3.x milestone.

@yuhong
Copy link

yuhong commented Aug 18, 2019

@mangod9
Copy link
Member

mangod9 commented Jul 9, 2021

Hoping this will be enabled as part of Regions work.

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

No branches or pull requests

5 participants