microsoft / go-winio

Win32 IO-related utilities for Go
MIT License
946 stars 180 forks source link

Set FILE_FLAG_FIRST_PIPE_INSTANCE flag #269

Open rtonini-r7 opened 1 year ago

rtonini-r7 commented 1 year ago

Is it possible to set FILE_FLAG_FIRST_PIPE_INSTANCE when creating listener. It seems theres no API exposing this when calling winio.ListenPipe(...). We need this functionality as it will prevent Instance Creation Race Conditions as detailed here https://csandker.io/2021/01/10/Offensive-Windows-IPC-1-NamedPipes.html#instance-creation-race-condition.

I noticed the comment on listener call here https://github.com/microsoft/go-winio/blob/650a2e464c7458a1d355d7bb5affad1eec1bfbb6/pipe.go#L444

Is this enforced? From testing I noticed if I try to run a second listener with same pipe, same configs it gave me open \\.\pipe\pipename: Access is denied.

Does this ensure no instances of the pipe were created before me?