Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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?



In reply to Good IPC Message Protocols? by pileofrogs

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2020-10-29 11:33 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (270 votes). Check out past polls.