PTOKEN NewToken;
PSECURITY_QUALITY_OF_SERVICE CapturedSecurityQualityOfService;
BOOLEAN QoSPresent;
+ OBJECT_HANDLE_INFORMATION HandleInformation;
NTSTATUS Status;
PAGED_CODE();
+ if (TokenType != TokenImpersonation &&
+ TokenType != TokenPrimary)
+ return STATUS_INVALID_PARAMETER;
+
PreviousMode = KeGetPreviousMode();
if (PreviousMode != KernelMode)
SepTokenObjectType,
PreviousMode,
(PVOID*)&Token,
- NULL);
+ &HandleInformation);
if (!NT_SUCCESS(Status))
{
SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService,
}
}
+ /*
+ * Fail, if a primary token is to be created from an impersonation token
+ * and and the impersonation level of the impersonation token is below SecurityImpersonation.
+ */
+ if (Token->TokenType == TokenImpersonation &&
+ TokenType == TokenPrimary &&
+ Token->ImpersonationLevel < SecurityImpersonation)
+ {
+ ObDereferenceObject(Token);
+ SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService,
+ PreviousMode,
+ FALSE);
+ return STATUS_BAD_IMPERSONATION_LEVEL;
+ }
+
Status = SepDuplicateToken(Token,
ObjectAttributes,
EffectiveOnly,
{
Status = ObInsertObject((PVOID)NewToken,
NULL,
- DesiredAccess,
+ (DesiredAccess ? DesiredAccess : HandleInformation.GrantedAccess),
0,
NULL,
&hToken);