How can a masters student compensate for lack of solid foundation in basic math and CS fundamentals?
That you realize this is good, but the appropriate approach depends on lots of individual factors. The people who are likely to be able to give you the best advice are your professors/advisor. They probably know best where you are at and what is most important for you to succeed in their program. Also, informing them that you are aware of your deficiencies and are trying to make up for them should improve their opinions of you, and also make them more willing to help you succeed in the program.
That said, here are some things that can help: start tutoring or TAing for lower level math/CS classes (I first really understood eigenvectors when I was tutoring other students in linear algebra), going through texts on your own (exercises are the most important!), taking/sitting in on undergrad classes (some of our grad students with weak backgrounds do this), typing up your own notes on this fundamental material, finding people (students or faculty) you can ask specific questions.
Also: read up on the impostor syndrome (on wiki-p and here, say). You may have it.
Take the relevant (even low-level) courses to fill out your knowledge is probably best. You might consider asking the teacher to attend classes without grading, or ask them to suggest material for self-study and self-assessment. There are lots of freely available lecture notes, even classes with complete homework and exams (sometimes over several years) and often complete solutions.
One thing I found out the hard way about self study is that (as far as viable) just-in-time learning is best. Seeing where you will apply the material helps with motivation, avoids getting lost in unproductive side branches, and "hands-on" learning is more fruitful. Besides, "learn this because I might need it" can be a mistake (it is never used), happens too soon (when the use comes around, you have all but forgotten about it), or (even worse) a better technique comes by, and you'll have to learn that on-the-job anyway.
Yes, this will take time. Perhaps even lots of it. But as I tell my students, better leave late with a degree than soon with nothing.