 ```ts
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    // Ignore blank lines and comments
    if (!line.trim() || line.trim().startsWith("#")) {
      continue;
    }

    const trimmedLine = line.trim();
    const parts = trimmedLine.split("=", 1);

    if (parts.length < 2) {
      throw new Error(`Invalid line: ${line}`);
    }

    const key = parts[0].trim();
    const value = parts[1].trim();

    // Check for empty key and prototype pollution
    if (!key || Object.prototype.hasOwnProperty(key)) {
      throw new Error(`Invalid key in line: ${line}`);
    }

    config[key] = value;
  }
  return config;
}
```