Despite the visibility promotion, Closures do not present any new security issue.
This is because of the simple reason, that visibility (i.e. private/public) is not a security mechanism in the first place.
Just because you marked your password field as private
, doesnt mean it is not accessible. It's not accessible, but only to code that behaves nicely.
It's still accessible easily in code, e.g. via reflection. (Of course, consumers of your class shouldn't do that...)
And that's even without going into things like debugging, memory inspection, etc...
So - as I said, it doesnt affect the level of security. You'd need to protect that Password field, but you'd need to do that anyway.
(Suggestion: store passwords as SecureString
instead of strings... )