Skip to content

Commit 5f6dea1

Browse files
wyrichteMikeHolman
authored andcommitted
[CVE-2019-0644] Chakra - AV due to type confusion - Individual - Given a split scope (a function has both a param and body scope), then it is required that the body and param scope are marked as both requiring either a scope object or a scope slot. This was not being enforced in Scope::SetIsObject(). This led to an AV in the interpreter when accessing a property because StLocalSlot was used instead of StLocalObjSlot.
1 parent fc9892c commit 5f6dea1

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/Runtime/ByteCode/ByteCodeGenerator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,6 +2944,12 @@ FuncInfo* PostVisitFunction(ParseNodeFnc* pnodeFnc, ByteCodeGenerator* byteCodeG
29442944
Scope::MergeParamAndBodyScopes(pnodeFnc);
29452945
Scope::RemoveParamScope(pnodeFnc);
29462946
}
2947+
else
2948+
{
2949+
// A param and body scope exist for the same function, they
2950+
// should both either be using scope slots or scope objects.
2951+
Assert_FailFast(top->bodyScope->GetIsObject() == top->paramScope->GetIsObject());
2952+
}
29472953

29482954
FuncInfo* const parentFunc = byteCodeGenerator->TopFuncInfo();
29492955

lib/Runtime/ByteCode/Scope.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,18 @@ void Scope::SetIsObject()
6969
});
7070
}
7171

72-
if (this->GetScopeType() == ScopeType_FunctionBody && funcInfo && !funcInfo->IsBodyAndParamScopeMerged()
73-
&& funcInfo->paramScope && !funcInfo->paramScope->GetIsObject())
72+
// If the scope is split (there exists a body and param scope), then it is required that the
73+
// body and param scope are marked as both requiring either a scope object or a scope slot.
74+
if ((this->GetScopeType() == ScopeType_FunctionBody || this->GetScopeType() == ScopeType_Parameter)
75+
&& funcInfo && !funcInfo->IsBodyAndParamScopeMerged())
7476
{
75-
// If this is split scope then mark the param scope also as an object
77+
// The scope is split and one of the scopes (param or body) is being set
78+
// as an object, therefore set both the param and body scopes as objects.
79+
Assert(funcInfo->paramScope);
7680
funcInfo->paramScope->SetIsObject();
81+
82+
Assert(funcInfo->bodyScope);
83+
funcInfo->bodyScope->SetIsObject();
7784
}
7885
}
7986

0 commit comments

Comments
 (0)