Sweat is secreted by sweat glands in the skin. It consists of water and sodium chloride (table salt). Like all salts, sodium chloride dissolves in water into positive and negatively charged ions—in this case, sodium (positive) and chloride (negative).
In a person with normal skin glands, much of the sodium and chloride ions in sweat are reabsorbed by cell structures called ion channels—one type for sodium and another for chloride. The chloride channels require a protein called CFTR to function properly.
In cystic fibrosis, a person carries two defective copies of the gene for the CFTR protein. As a result, the body produces either defective CFTR or none at all. Without fully functional CFTR, chloride cannot be reabsorbed properly from sweat. As a result, excessive amounts of chloride remain on the skin.
The chloride channels also indirectly regulate sodium absorption. Positively-charged sodium ions are attracted to negatively charged chloride ions, so they tend to move in the same direction. When excess chloride remains on the skin, excess sodium remains there as well.