One could perhaps do a small modification of the macro that actually draws the delimiters. See the block right after \makeatletter in the code below. Only two lines are changed, see comments in the code.

\documentclass[margin=0.5cm]{standalone}
\usepackage{mathtools}
% CODE BELOW FROM https://tex.stackexchange.com/a/1070/128068
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing}
%Set various styles for the matrices and braces.
\tikzset{
mymatrixenv/.style={decoration=brace,every left delimiter/.style={xshift=1pt},every right delimiter/.style={xshift=-1pt}},
mymatrix/.style={matrix of math nodes,left delimiter=[,right delimiter={]},inner sep=4pt,column sep=1em,row sep=0.5em,nodes={inner sep=0pt}}
}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% code from tikzlibrarymatrix.code.tex
\makeatletter
\def\tikz@delimiter#1#2#3#4#5#6#7#8{%
\bgroup
\pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name}%
node[outer sep=0pt,inner sep=0pt,draw=none,fill=none,
yshift=0.1#8, % <-- added this
anchor=#1,at=(\tikz@last@fig@name.#2),#3]
{%
{\nullfont\pgf@process{\pgfpointdiff{\pgfpointanchor{\tikz@last@fig@name}{#4}}{\pgfpointanchor{\tikz@last@fig@name}{#5}}}}%
% changed two occurrences of 0.5#8 to 0.55#8 in this line:
$\left#6\vcenter{\hrule height .55#8 depth .55#8 width0pt}\right#7$%
}
\pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name}%
\egroup%
}
\makeatother
\begin{document}
\begin{tikzpicture}[baseline=0cm,mymatrixenv]
\matrix [mymatrix,inner sep=0pt,
row sep=0em,column sep=0em,
nodes in empty cells,nodes=draw,draw=red] (m)
{
\dfrac{C}{D} & 2 & 3 \\
1 & 2 & \dfrac{A}{B} \\
1 & \dfrac{A}{B} + \dfrac{A}{B} & 3 \\
};
\draw [blue,thick] (m.north) -- (m.south);
\end{tikzpicture}
\end{document}
Old answer
Add outer ysep=1mm (or some other value) to the \matrix options. This moves the anchors

\documentclass[margin=0.5cm]{standalone}
\usepackage{mathtools}
% CODE BELOW FROM https://tex.stackexchange.com/a/1070/128068
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing}
%Set various styles for the matrices and braces.
\tikzset{
mymatrixenv/.style={decoration=brace,every left delimiter/.style={xshift=1pt},every right delimiter/.style={xshift=-1pt}},
mymatrix/.style={matrix of math nodes,left delimiter=[,right delimiter={]},inner sep=4pt,column sep=1em,row sep=0.5em,nodes={inner sep=0pt}}
}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
\begin{tikzpicture}[baseline=0cm,mymatrixenv]
\matrix [mymatrix,inner sep=0pt,
outer ysep=1mm, % <-- added this
row sep=0em,column sep=0em,nodes in empty cells,nodes=draw,draw=red] (m)
{
\dfrac{C}{D} & 2 & 3 \\
1 & 2 & \dfrac{A}{B} \\
1 & \dfrac{A}{B} + \dfrac{A}{B} & 3 \\
};
\end{tikzpicture}
\end{document}
m.northandm.south? Is that right? For example, if you try\draw (m.north) -- (m.south);with and without settingouter ysepto some value, they are different. But the size of the red bounding box remains the same. I want the size of the red bounding box to remain the same, that's fine. But I want to draw a line from the north and south edges of that red bounding box, do you know what coordinates I should be using instead ofm.northandm.south? – Milo Jul 25 '18 at 23:10\draw ([yshift=-1mm]m.north) -- ([yshift=1mm]m.south);works of course. But that's not an option for me as it depends on knowing the value ofouter ysepwhich doesn't work with what I'm trying to do in Automatically find which nodes are closest, to aid drawing lines within a TikZ matrix. – Milo Jul 25 '18 at 23:28inner sepandrow sep. For example, tryinner sep=2pt, row sep=1em. It's a small difference, I'll admit, but nonetheless there. Don't know if that's something to be concerned about? – Milo Jul 26 '18 at 00:55