Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (11)
    As of 2014-12-26 16:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (172 votes), past polls