Issue 268 in noda-time: Add the AllowPartiallyTrustedCallers attribute to the assembly

52 views
Skip to first unread message

noda...@googlecode.com

unread,
Jan 29, 2014, 10:28:47 AM1/29/14
to noda...@googlegroups.com
Status: New
Owner: ----

New issue 268 by paulbole...@hotmail.com: Add the
AllowPartiallyTrustedCallers attribute to the assembly
http://code.google.com/p/noda-time/issues/detail?id=268

What situation does this request make simpler?
ASP.Net code running at less than full trust (eg medium trust) cannot call
into a strong named assembly unless it has the AllowPartiallyTrustedCallers
attribute. Partially trusted code (anything less than full trust) that
calls a signed, strongly named assembly that doesn't have the attribute
will receive the error "That assembly does not allow partially trusted
callers."

Can you provide a straw-man example of what you'd want the API to look
like?
No changes to the API, but the implication is that any code in NodaTime
that might pose a security risk would have to make it's own, explicit
security demands. I'm not real proficient in the Code Access Security stuff
but this is what I gather from reading. From what I gather, if for example,
NodaTime had a utility class that accessed the registry to update timezone
data, you would not want partially trusted code to do that, so you would
want to explicitly demand a higher security level for that portion of code
to execute, either by placing a security attribute on specific methods or
by calling Assert on a permission object in code. The first method is
covered a lot. The only thing I've found on the later method is this
article: http://support.microsoft.com/kb/839300.

The remarks in the docs for AllowPartiallyTrustedCallersAttribute is a good
place to start:
http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute%28v=vs.110%29.aspx
One of it's links is to "Using Libraries from Partially Trusted Code"
(http://msdn.microsoft.com/en-us/library/8skskf63%28v=vs.110%29.aspx) which
has a subtopic "Requiring Full Trust for Types Within an APTCA Assembly"
which discusses using attributes on methods to raise the security level.
There's also a change in .Net 4 that is mentioned in many articles and
there is a question/response on stackoverflow that laid some of that out
(http://stackoverflow.com/questions/5055632/net-4-allowpartiallytrustedcallers-attribute-and-security-markings-like-secur)

This issue also came up with the Recaptcha .net library I was using
(http://code.google.com/p/recaptcha/issues/detail?id=100). They've
implemented the attribute in the code but I don't think they've made
another release containing it. You might try contacting the programmers on
that project.


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

noda...@googlecode.com

unread,
Jan 31, 2014, 9:42:53 AM1/31/14
to noda...@googlegroups.com
Updates:
Status: Accepted
Labels: Type-Enhancement Milestone-1.3.0

Comment #1 on issue 268 by jonathan.skeet: Add the
AllowPartiallyTrustedCallers attribute to the assembly
http://code.google.com/p/noda-time/issues/detail?id=268

Okay - I think it's reasonable to put this in the desktop build, but the
PCL build is a bit more of a pain. The attribute appears not to be
supported in Silverlight or Windows Phone, both of which are supported by
our current PCL build.

I'd rather not fork the PCL build at the moment - do you think that having
it just for the desktop build will satisfy most users?

noda...@googlecode.com

unread,
Jan 31, 2014, 11:07:41 AM1/31/14
to noda...@googlegroups.com

Comment #2 on issue 268 by paulbole...@hotmail.com: Add the
AllowPartiallyTrustedCallers attribute to the assembly
http://code.google.com/p/noda-time/issues/detail?id=268

I don't know about "most", but just adding it to the desktop build would
make the library more easy to implement for ASP.Net development on a lot of
shared hosting accounts. Web development is where I spend all of my time,
so I wouldn't know how much the issue might be affecting other usage
scenarios. To be honest I'm surprised no one has reported the issue
already, either most asp.net development is in full trust environments or
programmers writing code for low cost sites aren't taking the time to
utilize such awesome libraries as Noda Time. (I don't under stand why.
Using the Period object in my ecommerce site saved me a lot of lines of
code while giving the end user more flexibility. Just define the period on
a subscription product using the Iso pattern and I can extend the
expiration date on the account in just a few lines of code. Selling in
months or years. Fine. Offering free trials for days or weeks. Sure, no
problem... LocalDateTime.Plus(Period)!)

noda...@googlecode.com

unread,
Jan 31, 2014, 2:33:05 PM1/31/14
to noda...@googlegroups.com
Updates:
Status: Fixed

Comment #3 on issue 268 by jonathan.skeet: Add the
AllowPartiallyTrustedCallers attribute to the assembly
http://code.google.com/p/noda-time/issues/detail?id=268

Right. In that case I'll mark it as fixed for the moment (revision
2f1ea405b87d), and we'll see if anyone complains about it for the PCL :)

Claudia Murialdo

unread,
May 5, 2023, 1:37:55 PM5/5/23
to Noda Time
The  APTCA  was removed at 3.0.0 (d62f69b)
Would it be possible to add  AllowPartiallyTrustedCallersAttribute  again ?
It allows to use nodatime in some Brazilian hostings for ASP.NET that requires medium trust.

Jon Skeet

unread,
May 5, 2023, 1:43:47 PM5/5/23
to noda...@googlegroups.com
I'm definitely not going to just revert the change. As noted in the commit log, "This causes issues with C# 7.2 features".

I would suggest there are a few options you could take:
  • You could use Noda Time 2.4.x and download the latest NZD file to keep up with the latest time zone changes
  • You could fork Noda Time for your own use (but you'd need to be responsible for keeping it up to date etc)
  • You could investigate the issues with C# 7.x, and create a PR with clear explanations of why this is required and what all the implications might be. The fact that this is the first time it's been requested since 3.0 was released nearly 3 years (and many million downloads) ago suggests that this is a really rare requirement in modern hosting.
Jon


--

---
You received this message because you are subscribed to the Google Groups "Noda Time" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noda-time+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/noda-time/c962810b-fa9b-44ae-a4ae-aa675c4bbb96n%40googlegroups.com.

Claudia Murialdo

unread,
May 5, 2023, 2:46:22 PM5/5/23
to Noda Time
Ok. I will try the first option. 
Regards,
Claudia.

Claudia Murialdo

unread,
May 5, 2023, 3:10:12 PM5/5/23
to Noda Time
First option does not work. Using NodaTime 2.4.18, with medium trust in aspnet gives the following error:

Inheritance security rules violated while overriding member: 'NodaTime.Offset.System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

It seems an error inside the library. It happens with version 2.0.0 also. :(.

Jon Skeet

unread,
May 5, 2023, 3:14:29 PM5/5/23
to Noda Time
In that case, I'm afraid this is something you'll need to look into yourself. This isn't an aspect I have the time to look into.

Reply all
Reply to author
Forward
0 new messages