8. Given a positive integer $n$. Use 26 white unit cubes and 1 black unit cube to form a $3 \times 3 \times 3$ cube. Then use $n^{3}$ such cubes to form a cube with edge length $3 n$. Question: What is the minimum number of white unit cubes that need to be painted red so that each remaining white unit cube is adjacent to at least one red unit cube?
8. $(n+1) n^{2}$.

Let the unit cube be referred to as a small cube.
Establish a coordinate system such that the centers of each small cube along the three coordinate axes have coordinates ranging from $1 \sim 3 n$. Each small cube is identified by the coordinates of its center. Thus, a small cube is black if and only if all three of its coordinate values are congruent to 2 modulo 3.

Color the small cube with coordinates $(a, b, c)$ red if: $a$ is a multiple of 3, $b \equiv 2(\bmod 3)$, and $c \equiv 2(\bmod 3)$;
Color the small cube with coordinates $(1, b, c)$ red if: $b \equiv 2(\bmod 3)$ and $c \equiv 2(\bmod 3)$.

A total of $(n+1) n^{2}$ red small cubes are obtained, and the requirements of the problem are met.

Next, we need to prove that the number of red small cubes cannot be less than $(n+1) n^{2}$.
For $i=1,2, \cdots, n$, let
$w_{3 i}=i, w_{3 i-1}=0, w_{3 i-2}=n+1-i$.
It is easy to see that the sequence $\left\{w_{i}\right\}$ is
$n, 0,1, n-1,0,2, n-2, \cdots, 1,0, n$.
On the small cube with coordinates $(a, b, c)$, write $w_{a} w_{b} w_{c}$. Thus, the sum of the numbers written on all small cubes is
$$
M=\left(w_{1}+\cdots+w_{3 n}\right)^{3}=n^{3}(n+1)^{3} .
$$

Define the price of a small cube $X$ as the sum of the numbers written on the small cubes (including $X$ itself) that share a common point with $X$. Thus, in any coloring method, the sum of the numbers written on the red small cubes is not less than $M$.

We now prove: For any white small cube $X$,
$$
S(X) \leqslant(n+1)^{2} n \text {. }
$$

From this, it follows that at least
$$
\frac{M}{(n+1)^{2} n}=(n+1) n^{2}
$$

small cubes must be colored red, which is what we need to prove.
Let the coordinates of the small cube $X$ be $(a, b, c)$. The small cubes that share a common point with $X$ have a horizontal coordinate equal to $a$ or $a \pm 1$, and similarly for the other two coordinates.
$$
\begin{array}{l} 
\text { Then } S(X) \\
=\left(w_{a-1}+w_{a}+w_{a+1}\right)\left(w_{b-1}+w_{b}+w_{b+1}\right) . \\
\left(w_{c-1}+w_{c}+w_{c+1}\right),
\end{array}
$$

where, $w_{0}=w_{3 n+1}=0$.
Notice that,
$$
w_{t-1}+w_{t}+w_{t+1}=\left\{\begin{array}{ll}
n, & t \neq 2(\bmod 3) ; \\
n+1, & \text { otherwise. }
\end{array}\right.
$$

Since the coordinates of the small cube $X$ are not all congruent to 2 modulo 3,
$$
S(X) \leqslant(n+1)^{2} n \text {. }
$$