[backend] Lock credentials file during read to prevent race conditions.