[Mono-dev] Why does Mono's CoreCLR blocks internal method reflection from transparent code ?

nelson nelson.cabral at gmail.com
Tue Mar 26 13:47:34 UTC 2013


Thank you very much for your answer, I was afraid of having no one
answering me. By default the .Net Framework allows it and some frameworks
do not work on CoreCLR because of this restriction. Even transparent code
from platform code is blocked.

I bypassed it by editing mono's source code but I would like to know if
there is a security reason behind it.

2013/3/26 Rolf Bjarne Kvinge-4 [via Mono] <
ml-node+s1490590n4659156h66 at n4.nabble.com>

> I believe you're asking the wrong question: why should CoreCLR allow
> transparent code to call internal methods? It doesn't matter if
> they're transparent or not, there's a reason a method is internal and
> you can make the object confused if internal methods are called
> directly.
>
> Rolf
>
> On Sun, Mar 24, 2013 at 7:08 PM, nelson <[hidden email]<http://user/SendEmail.jtp?type=node&node=4659156&i=0>>
> wrote:
>
> > I'm checking that code, at
> >
> https://github.com/mono/mono/blob/master/mono/metadata/security-core-clr.c.
>
> >
> > If to "ensure that the specified method can be used with reflection
> since
> > Transparent code cannot call Critical methods" is fine with me, why does
> > CoreCLR also prevents transparent code to call internal transparent
> methods
> > or properties through reflection ?
> >
> > I'm not a security expert, and am curious to know if removing this check
> > affects mono clr's security.
> > I'm comparing the code below to this page about CoreCLR :
> > http://www.mono-project.com/Moonlight2CoreCLR .
> >
> > Details :
> >
> > /*
> >  * mono_security_core_clr_ensure_reflection_access_method:
> >  *
> >  *  Ensure that the specified method can be used with reflection since
> >  *  Transparent code cannot call Critical methods and can only call them
> >  *  if they are visible from it's point of view.
> >  *
> >  *  A MethodAccessException is thrown if the field is cannot be
> accessed.
> >  */
> > void
> > mono_security_core_clr_ensure_reflection_access_method (MonoMethod
> *method)
> > {
> >     MonoMethod *caller = get_reflection_caller ();
> >     /* CoreCLR restrictions applies to Transparent code/caller */
> >     if (mono_security_core_clr_method_level (caller, TRUE) !=
> > MONO_SECURITY_CORE_CLR_TRANSPARENT)
> >         return;
> >
> >     if (mono_security_core_clr_get_options () &
> > MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION) {
> >         if (!mono_security_core_clr_is_platform_image
> > (method->klass->image))
> >             return;
> >     }
> >
> >     /* Transparent code cannot invoke, even using reflection, Critical
> code
> > */
> >     if (mono_security_core_clr_method_level (method, TRUE) ==
> > MONO_SECURITY_CORE_CLR_CRITICAL) {
> >         mono_raise_exception (get_method_access_exception (
> >             "Transparent method %s cannot invoke Critical method %s.",
> >             caller, method));
> >     }
> >
> >     /* also it cannot invoke a method that is not visible from it's
> (caller)
> > point of view */
> >     if (!check_method_access (caller, method)) {
> >         mono_raise_exception (get_method_access_exception (
> >             "Transparent method %s cannot invoke private/internal method
> > %s.",
> >             caller, method));
> >     }
> > }
> >
> > Hope someone can answer me...
> >
> >
> >
> > --
> > View this message in context:
> http://mono.1490590.n4.nabble.com/Why-does-Mono-s-CoreCLR-blocks-internal-method-reflection-from-transparent-code-tp4659140.html
> > Sent from the Mono - Dev mailing list archive at Nabble.com.
> > _______________________________________________
> > Mono-devel-list mailing list
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4659156&i=1>
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> _______________________________________________
> Mono-devel-list mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4659156&i=2>
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://mono.1490590.n4.nabble.com/Why-does-Mono-s-CoreCLR-blocks-internal-method-reflection-from-transparent-code-tp4659140p4659156.html
>  To unsubscribe from Why does Mono's CoreCLR blocks internal method
> reflection from transparent code ?, click here<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4659140&code=bmVsc29uLmNhYnJhbEBnbWFpbC5jb218NDY1OTE0MHwtMTUzMDQxMDg0Nw==>
> .
> NAML<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Nelson Cabral




--
View this message in context: http://mono.1490590.n4.nabble.com/Why-does-Mono-s-CoreCLR-blocks-internal-method-reflection-from-transparent-code-tp4659140p4659157.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130326/bed53adc/attachment.html>


More information about the Mono-devel-list mailing list