실제 사용되는 "코드 액세스 보안"이 있습니까?
경고:
.Net 및 .Net 코어의 최신 버전은이 질문이 제기 된 이후 "코드 액세스 보안"(CAS)을 제거 및 / 또는 변경했습니다.
원래 질문 :
저는 70-536 .NET Framework-Application Development Foundation Exam 을 공부하는 과정에 있습니다. 수년 동안 .net을 프로그래밍 해 왔기 때문에 어렵지 않습니다!
하지만 CAS (Code Access Security)에 대해 배워야합니다. 사용하거나 구성 할 필요가 없었기 때문에 다른 사람이 실제 사용 방법을 찾았는지 궁금합니다.
CAS를 사용한 적이 있고 문제가 아닌 솔루션의 일부인 사례를 제공하십시오.
(지금까지 다른 모든 것은 .NET 프로그래밍 기간 동안해야했던 작업과 관련이 있습니다.)
관련 질문 :
- CAS (Code Access Security)를 사용하는 이유는 무엇입니까? -Microsoft가 사용하는 방식을 제외하면 실제 사례가 거의 없습니다.
- 실제로 코드 액세스 보안을 사용하여 어셈블리 및 / 또는 메서드를 보호하는 사람이 있습니까?
- .NET의 코드 액세스 보안이란 무엇입니까? -CAS를 잘 정의하지만 실제 예제는 제공하지 않습니다.
- . NET 코드 액세스 보안 : 유용하거나 지나치게 복잡합니까?
지금까지의 결과.
CAS는 타사 코드를 호스팅 할 때 유용합니다. 예를 들어 웹 호스팅 회사는이를 사용하여 고객의 Asp.net 코드가 서버를 손상시키는 것을 막을 수 있습니다. (Office는 .NET을 VBA 대신 사용할 때도 사용합니다.)
지금까지 Microsoft 응용 프로그램 외부에서 사용 된 유일한 자세한 예는 다음과 같습니다.
최근에 제가 한 프로젝트도 비슷한 일이있었습니다. 사용자가 라이브러리를 업로드하고 성능을 테스트 할 수 있도록합니다 ( "누가 최고의 알고리즘을 만드는지"). 말할 필요도없이 CAS가 많이 필요했습니다.
CAS는 미국 국방부와 같은 JITDC 인증을받는 데 유용 할 것 같지만 CAS가 실제 가치인지 아니면 그냥 박스 틱인지는 모르겠습니다.
(CAS를 사용하는 호스트를 우회해야하고 해당 컴퓨터에 대한 관리자 권한이있는 경우 어셈블리를 GAC에 넣을 수 있습니다.)
앞으로 CAS는 .net 4에서 조금 덜 복잡 합니다.
적어도 새로운 Microsoft 시험에는 CAS를 포함하는 "기초"시험이 없을 것 같습니다. 새로운 Winforms / WPF 시험에 들어갈 수 있을지 모르겠습니다.
저는 "실제 세계"에서 코드 액세스 보안을 자주 접하며, 예상치 못한 경우가 많습니다. 그리고 어떤면에서 SilverLight는 최종적 으로 CAS 를 전혀 사용하지 않기로 결정한 것이 아니라면 실세계에서 훌륭한 응용 프로그램이 될 것 입니다.
호스팅 제공 업체
실제로 작동하는 곳은 안전한 환경이 필요한 곳입니다. 물론 ASP.NET 자체가 필요하지만 ASP.NET 호스팅 공급자는 수정 된 보안 모델 을 사용하여 소중한 시스템에 대한 침입을 방지합니다. 나는 Webhost4Life가 이것을 사용한다는 사실을 알고 있습니다 (그 사이트에 대한 정보는 없지만 나는 그들과 함께 일해 왔으며 실제로 거기에 있습니다). 더 자세히 살펴보면 다른 ASP.NET 호스팅 공급자도 똑같이 수행하지만 이에 대해 명확하지 않습니다 . godaddy.com의 스레드 가 CAS를 변경하기를 원하지 않습니다 (지원되는 항목과 지원되지 않는 항목이 명확하지 않음) 또는 1 & 1 관련 토론 . 일부 클라우드 호스팅 사이트 (rackspacecloud)는 조금 더 나아가 "수정 된 완전 신뢰 수준을 위해 Microsoft와 협력"했습니다 .
간단히 말해서, ASP.NET 호스트를 찾으면 CAS를 사용하여 원하지 않는 일을하지 못하도록 막았을 가능성이 높습니다. 그들은 심지어 CAS에 완전히 다른 의미를 부여하는 "기본"(많은 제한) 호스팅과 "엔터프라이즈"(제한이 거의 없음) 호스팅을 구별 할 수도 있습니다.
CAS의 다른 응용
내가 직접 만난 몇 가지 실제 상황에서 너무 많이. 최근에 제가 한 프로젝트도 비슷한 일이있었습니다. 사용자가 라이브러리를 업로드하고 성능을 테스트 할 수 있도록 허용했습니다 ( "누가 최고의 알고리즘을 만드는지"). 말할 필요도없이 CAS가 많이 필요했습니다. 기타 예 또는 흥미로운 리소스 :
- NAR Loader (코드 프로젝트 애플리케이션)는 자체 CAS를 사용합니다.
- LR Evaluator (코드 프로젝트 앱이라고도 함)는 CAS를 사용합니다.
- ClickOnce (아래 참조)는 CAS를 사용합니다.
- CAS 디자인 패턴 : CAS를 사용하는 것으로 "가정"하는 인기
- CAS 이해 : 더 많은 인기와 일부 의견은 응용 프로그램을 암시합니다.
- Microsoft SharePoint는 항상 CAS를 사용 하는 것 같습니다 (죄송합니다. 저는 SP 전문가가 아닙니다)
자신이 직접 완전히 제어 할 수 있고 자체 앱과 코드를 빌드하고 (또는 빌드 한 경우) 시스템을 완전히 제어 할 수있는 상황에서는 CAS가 너무 자주 필요하지 않을 것입니다. 덜 신뢰할 수있는 소스 (기본적으로 완전히 제어 할 수없는 모든 것)에서 코드를 실행하는 순간 사용하는 것이 더 많습니다.
CAS 대 ClickOnce
기본 CAS 설정은 네트워크 공유 또는 기타 로컬이 아닌 소스에서 실행되는 코드의 기능을 제한합니다. 이것은 의미가 있지만 엄격한 제한으로 인해 분산 응용 프로그램을위한 중앙 저장소를 갖기가 어렵습니다. .NET 2.0은 보안을 강화하기 위해 ClickOnce를 도입했습니다 ( 여기에서 논의 ).
ClickOnce 자체 는 CAS 를 사용하여 설치 프로그램이 시스템 함수를 호출하지 못하도록합니다. 따라서 CAS에 의존하는 가장 잘 알려진 애플리케이션이라고 생각합니다 .
요점 : 공유에서 직접 실행할 수있는 항목을 만들려면 CAS를 이해해야합니다. 그렇지 않으면 모두 무시하고 ClickOnce를 사용합니다.
CAS에 대한 Microsoft의 설문 조사
2005 년에 Microsoft 는 CAS가 그토록 인기가없는 이유를 알아보기 위해 설문 조사 를 소집하여 CAS를 더 잘 적용 할 수 있도록 개선하기를 희망했습니다. 안타깝게도 실제 설문 조사 결과를 찾을 수 없었 습니다.이 게시물 외에는 CAS가 제대로 사용되지 않는 이유가 다소 자세히 설명되어 있습니다.
다른 세상의 CAS
그러나 그 게시물은 흥미로운 틈새 시장 인 CAS를 다른 세계에 적용한 Unix / Linux를 가리 킵니다. 그들은 그것을 CAS라고 부르지 않고 대신 BitFrost 입니다. 실제 응용 프로그램의 경우 는 어떻습니까? 전통적인 Unix 보안 모델을 대체하기 위해 BitFrost에 의존 하는 "One Laptop Per Child"프로젝트 .
업데이트 : Unix / Linux의 CAS 섹션 인 BitFrost 및 설문 조사 섹션.
업데이트 : ClickOnce를 절 대 CAS 추가
업데이트 : CAS를 사용하여 리소스의 추가 목록 (행의 모든 업데이트와 사과!)
기술적으로 매우 세분화 된 권한 사양을 허용하므로 매우 유용합니다. 이것은 당신과 (이론적으로 보안 취약점을 악용하는 것을 훨씬 더 어렵게 만듭니다. 공격자가 당신의 앱을 완전히 제어하더라도 그는 여전히 CAS Sandbox에 갇혀 있습니다) 그리고 당신의 고객에게도 좋습니다. 애플리케이션은 자체 보안 감사를 수행하고 실행할 수 있습니다.)
실제로 사용하면 대부분 의미가 없습니다. 나는 그것이 너무 복잡하고 사용 가능한 개발 도구에 의해 지원되는 것이 너무 적고 대부분의 사용자는 어쨌든 상관하지 않는다고 생각합니다.
물론 예외가 있습니다 (.net / CAS를 실제로 알고있는 정부 및 고객). CAS가 절대적으로 유용하고 필수라고 말하고 싶지만 현실은 명확한 언어를 사용합니다.
독자 참고 사항 : 아래 두 개의 주석을 참조하십시오. 실수로 CAS의 정의를 부풀려 RBS를 (잘못) 포함하는 것 같습니다. 여기에 참고 용으로 답변을 남겨 두 겠지만 차이점에 유의하십시오.
CAS에는 두 가지 문제가 있습니다. 이 시험에서 가장 많이 볼 수있는 것은 다른 코드를 호출하는 코드에 대한 모든 뉘앙스입니다. 이는 부분 신뢰에 유용 할 수 있지만 대부분의 경우 단순히 고통입니다. 대부분 / 너무 많이 수행합니다) 실제로 실행되지 않습니다 (완전히 건너 뜁니다).
The useful part of CAS RBS is principal permission, which is used; of course, your UI should verify access to features, but you can put (in your low-down logic):
[PrincipalPermission(SecurityAction.Demand, Role = "ADMIN")]
static void DeleteOrder(int id) { ... }
This will be enforced even in full trust; you can define your own principal (tied to the user) by implementing IPrincipal
(look at IsInRole()
). And since principals are supported in most environments (winforms, webforms, mvc, wcf, etc) this can make for a very flexible way to double-check security at the business layer without having to reference the specific security model. Note that the above check would work in any environment.
You can also perhaps use this to drive your UI. I did have a usenet post that enabled / disabled winforms controls based on the principal (using runtime properties to specify the role per control, a bit like ToolTip
etc) - I can't find it at the minute, though (edit: maybe this one).
The thing to understand about Code Access Security is that it is of very little use to an application developer beyond understanding how it is being used and at what permission level for API's that you may be calling. The only exception to this, that I have really found useful is a CAS called PrincipalPermission, it basically doesn't allow certain code to be executed if the right Role isn't defined for the current Principal. See this post on it:
http://www.coderjournal.com/2008/03/securing-mvc-controller-actions/
The developers that really need to pay attention to CAS and how it should be implemented in their application is the framework and code library developers. Because there is certain levels of trust that you need to demand inorder for your application to work especially when dealing with unmanaged resources such as files, network streams, serial ports, etc. Or if you are creating the code for that unmanaged resource like some speicalized server, or any kind of low level access in to your assemblies you will want to create some code access security around it so that people aren't allowed to execute something that has been strictly denied to them.
It doesn't help that Microsoft hasn't really done that great of a job explaining how CAS should be used in every day application. So that is really the reason for lack of use. However CAS is one of the many reasons that .NET is such a secure language and suffers from a lot fewer problems than its competitors.
I was the development lead on a project to get JITC certification (US Department of Defense) for a .NET based solution, and the CAS settings were scrutinized very closely during the certification testing.
Like most of the other certification requirements, the code could only use the privileges it needed to work and no more.
If you are planning to get security certifications CAS can definitely be important.
One thing you should know is that Code Access Security is pretty much broken as a method for tamper-proofing. See:
CAS Tamper-Proofing is Broken: Consequences for Software Licensing
...
Code Access Security can no longer be relied upon to prevent the use of tampered assemblies in shipped products. This means that if your application is dependent upon Code Access Security to perform licensing checks, it is trivial for an attacker to replace your licensing assembly with another, thereby gaining free access to your application.
...
Although I've never used it, my understanding of CAS was that it could also be used to expand object-oriented design mechanics. For example, say you are developing a massive data access package for a bank that must implement database access and caching. Even though they are part of the same deployment package, given the hypothetical size of the project, the logic should be implemented in separate assemblies since they are sufficiently different problem sets that hinge on different external forces (database infrastructure vs consumer usage).
However, the caching code might need to access some sensitive classes or methods in the data access assembly that consumers of the overall package shouldn't have access to. Therefore these data access classes and methods can't simply be public
. Protected methods in the data access assembly with subclasses in the caching assembly could get around some cases, but often times it's an abuse of inheritance. It might simply be more elegant to leave them public
with LinkDemands placed on callers for a custom Permission (e.g. DataPackagePermisson
) that administrators would only grant to the caching assembly.
We used CAS for our Applications was not really to hard, since we'd only tried to stop unauthuorized code execution. Problems came up once using our software from local network share, but a cas-policy cleaned the problem out.
- We secured all our assemblies using a strong name.
- We created a cas-policy for all assemblies with our strong name and allowed code signed with our strong name to start from local area network and locally placed code.
- Assemblies loaded from local area network needing local file access (component for burning data cds) needed to get the link-demand attribute on all public classes.
Since update of .NET3.5 our problems were not existent anymore, since code on local area network is now handled like local code.
참고URL : https://stackoverflow.com/questions/1566934/is-code-access-security-of-any-real-world-use
'programing tip' 카테고리의 다른 글
iPhone을 백그라운드에서 iBeacon으로 실행 (0) | 2020.11.09 |
---|---|
Xcode 7 iOS 9 UITableViewCell Separator Inset 문제 (0) | 2020.11.09 |
PDO 사용 방법에 대한 좋은 튜토리얼이 있습니까? (0) | 2020.11.09 |
런타임에 Spring Bean 정의를 바꿀 수 있습니까? (0) | 2020.11.09 |
복제 된 리포지토리에서 풀 요청을 제출하는 방법은 무엇입니까? (0) | 2020.11.09 |