Added security check to attachment class