They don't serve 3rd party ads, but they use it as a job board (with closed comments on those posts, LOL) for their companies, and to announce product launches and such. All that stuff gets boosted, nobody's organically up-voting a comments-disabled job post from some mediocre startup.
[EDIT] The less-direct part, yes, is stuff like brand awareness and community goodwill.
You also see some posts on here about some YC founded company or other with open positions, which is a wider audience (so that helps the equation I guess).
My guess is that these two target audiences together is enough for them. It is not like HN is a heavy site, nor does it change much over the years. So with smart coding (i.e. a compiled language) and hosting my guess is that moderation time is the bulk of the actual operating costs.