From The Linux Programming Interface
If a set-user-ID-root program must create a file that initially it must own, but which will eventually be owned by another user, the file should be created so that it is initially not writable by other users, either by using a suitable mode argument to open() or by setting the process umask before calling open(). Afterward, the program can change its ownership with fchown(), and then change its permissions, if necessary, with fchmod(). The key point is that a set-user-ID program should ensure that it never creates a file that is owned by the program owner and that is even momentarily writable by other users.
I was wondering why "a set-user-ID program should ensure that it never creates a file that is owned by the program owner and that is even momentarily writable by other users"?