Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Gracious Monks!

I'm writing some client-server code, and while I've got no problem setting up the pipes, sockets or what-have-you, I've realised I don't know much about formatting the conversation that goes on over those pipes or sockets or what-have-you.

To be more specific, I have a server process with privileged access and clients that pass instructions to the server. The idea being to separate the privileged and mundane happenings. To be even more specific, this is in reference to Security, root and CGI?.

So, once I've got my sockets set up, what's the most secure, by that I mean limited, constrained, way to format the messages between my two processes?

I'd like to assume that my non-privileged client has been completely hacked, so I want to make it as hard as possible for the baddies to crack open the privileged process. I want to pretend bad guys can send anything at all down the socket at my privileged process.

For example, I could do something vague, like var = value separated by newline, ala:

NAME=Pileofrogs PASSWORD=whatadorkiam ACTION=delete_account

I'd rather do something more secure. I thought I still use var and value pairs, but I'd encode the vars and values and delimit them by a character outside that encodings resulting character set. So, maybe I'd base64 encode the vars and values and separate them with a ':', using a newline to separate records, ala (totally fake):

mngaskjfh:alkjsdhf78ask4834598asdfsd 098234jkasdhfsaljks:lkhasdflg97698 asdkhlalkj86987:jkhasldhdflkjdfg87696

(note: I'm not encrypting. I'm trying to make it really hard for the privileged process to miss-interpret the message it receives.)

Then, when I parse it out I only have 67 (65 from base64 plus ':' and '\n') acceptable characters, and I can drop any messages containing bad characters on the floor. Since ':' and '\n' aren't members of the base64 output list, splitting my vars and values will be a snap.

Obviously, this only helps me through one step. I have to decode and then use those vars and values, but now at least, I know which are vars and which are values.

So! My questions are: Does this make sense? Is there a better way to do this?

Thanks!

--Pileofrogs


In reply to Good IPC Message Protocols? by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found