Default installation permissions for wp-config.php

The web installer writes configuration data into that file. It needs write access for that.

I don’t think this was your backdoor. There was probably a plugin or an old theme with timthumb that had a vulnerability.