Encrypting attributes that leak your intent
Rename everything in a .NET assembly and one thing stays in plain English. A renamer turns your types and methods into a1 , b2 , c3 , but open the result in a metadata viewer and the custom attributes still read like a design document: [Obsolete("replaced by the new vault API")] , [Inject(typeof(IPaymentGateway))] , [assembly: InternalsVisibleTo("Acme.Billing.Tests")] . The symbols are gone; the…
Renaming methods and types in a .NET assembly is common, but attributes often still reveal the intended functionality. For example, the [Obsolete] attribute with a string message and the [Inject] attribute with a type argument can still be seen when inspecting the resulting metadata. Renaming only affects the names of types, methods, and fields, not attribute arguments, which are stored separately in a binary format in the #Blob heap.
Nebula Pro addresses this issue by applying a three-step process: stripping unnecessary attributes, encrypting sensitive attribute blobs, and rebuilding them through generated accessors.
To achieve this, Nebula first creates a policy that determines which attributes to treat differently. Custom attributes that the Common Language Runtime (CLR) consumes, like StructLayout or MarshalAs, must remain intact. Additionally, attributes read by third-party libraries during runtime, such as those used by DI containers or serializers, also cannot be encrypted. These attributes are simply left untouched.
For the remaining attributes, Nebula removes them entirely if they are only used at compile time, such as the [Obsolete] message. This prevents any sensitive information from being revealed in the final binary. When it comes to attributes the application itself needs to access, Nebula encrypts their blob contents and stores the encrypted data in the #Blob heap.
To access the encrypted data, Nebula provides a generated accessor that decrypts and reconstructs the original attribute on demand. This approach keeps sensitive information hidden while ensuring applications can still function as intended.
Rewritten by urgent.news; may contain errors — check the original. How we use AI.
Source: dev.to