[bugfix] Memory leak in security manager

@shabanovd I think this is the leak we were searching for.