AnswerBun.com

How to guarantee that that only a specific process reads from a named pipe?

Unix & Linux Asked by caveman on September 28, 2020

Suppose that, at time (1), I create a named pipe using Python with the goal that eventually this Python process would write something to that named pipe. Why? Because, at time (2), there is another process that is expected to read from that named pipe.

So, basically, it’s IPC via named pipes. Why is this neat? Because it looks like a file, so that the other process that can only read files, can be communicated to via this named pipe mechanism as a convenient IPC without needing to rewrite the other process.

But there is a problem: suppose that between time (1) and time (2), an evil process started reading from the named pipe 1st before that intended process. This way, my Python script may end up sending data to an unintended process. So I am not concerned if the hijacker starts writing to the process in my specific risk model (I’m only concerned about the hijacking reading from the pipe before the intended process).

Question: is there any mechanism to ensure no other process but the intended one reads from the IPC other than the intended process?

One Answer

Named pipes have file permissions just like any other file. Make sure that when you crete the pipe, the permissions are set such that only the account meant to run your process can read from it.

Answered by Joseph Sible-Reinstate Monica on September 28, 2020

Add your own answers!

Related Questions

scan from printer to pdf file via a network

1  Asked on December 3, 2021 by gfrustrated

   

DPMS does not standby my Samsung monitor

2  Asked on December 3, 2021 by mp-felder

 

is there any way to invert history_ignore in zsh?

1  Asked on December 3, 2021 by yahnweh-remixed

     

Find specific argument and pass it to command

2  Asked on December 3, 2021 by atlantic

   

Limit memory usage for a single Linux process

8  Asked on December 1, 2021 by ben-dilts

     

Command to list all usernames on a Linux server

4  Asked on December 1, 2021 by dac2002

     

Access denied for a particular user by PAM account configuration

4  Asked on December 1, 2021 by user5447339

     

Unix shell script using Expect shell

1  Asked on December 1, 2021 by satsensort

     

can’t change value in smp_affinity

1  Asked on December 1, 2021 by futureishere

   

How to: ZFS dataset per user

1  Asked on December 1, 2021

     

cryptsetup: bad password or options?

0  Asked on December 1, 2021 by gregoiregentil

     

How to prevent the program from accessing files?

1  Asked on December 1, 2021 by mihail-hrs

   

TNAS how to install wget

2  Asked on December 1, 2021 by mah-na-mah-na

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir