The structural and electronic properties of hydrogenated K-4 carbon as a new cubic gauche structure in I2(1)3 symmetry are investigated using first-principles calculations. The total energy for this carbon hydride (labeled by K-4-CH) is 0.47 eV per CH unit lower than that of solid molecular cubane, suggesting its energetic stability. Based on the calculated phonon dispersion curves and electronic band structure obtained by hybrid density functional method, we find that K-4-CH is dynamically stable and exhibits as an insulator with an indirect band gap of 6.07 eV, which is close to 6.10 eV of cubic gauche nitrogen (cg-N). To study the doping effect of nitrogen, we have also investigated N-doped K-4-CH with a composition of C4H4N4 in P2(1)3 symmetry. The phonon and electronic band structures show that it is dynamically stable and behaves as an insulator with an indirect band gap of 5.39 eV, smaller than that of both K-4-CH and cg-N. These results broaden our understanding of the cubic gauche structure.