Adding security context to threads to fix security problems