Language: JavaScript
Label: vulnerable
CWE: CWE-269 \u2014 Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.

Code:
const updateAccount = ({ id, accountStatus, adminRoleArn }) => {
    if (!id) return respondWithError("Internal error while trying to update account.", "Parameter 'id' missing.");
    if (!accountStatus)
        return respondWithError("Internal error while trying to update account.", "Parameter 'accountStatus' missing.");
    if (!adminRoleArn)
        return respondWithError("Internal error while trying to update account.", "Parameter 'adminRoleArn' missing.");
    let ddb = new AWS.DynamoDB.DocumentClient({
        region: region
    });
    return ddb
        .update({
            TableName: accountsTable,
            Key: {
                Id: id
            },
            UpdateExpression: "set AccountStatus = :s, AdminRoleArn=:r",
            ExpressionAttributeValues: {
                ":s": accountStatus,
                ":r": adminRoleArn
            },
            ReturnValues: "UPDATED_NEW"
        })
        .promise()
        .then((response) =>
            respondWithSuccess("DynamoDB table record for account " + id + " successfully updated.", response)
        )
        .catch((error) =>
            respondWithError("Error trying to update DynamoDB table record for account " + id + ".", error)
        );
};