
Static Analysis Tools. Although programming lan-
guages provide defensive mechanisms to prevent vul-
nerabilities, such as the sanitization functions (e.g.,
mysqli_real_escape_string in PHP), they can not
guarantee that the software produced is secure since
human errors remain inevitable. Supplementary tools
are, therefore, essential for validating the code pro-
duced and supporting developers throughout the de-
velopment process.
Static analysis is a strategy that involves analysing
the application source, intermediate or binary code
without executing it to detect errors and vulnerabil-
ities. There is a wide variety of static analysis tools,
but usually, they follow a similar approach. They start
by taking the code and building a model that repre-
sents it. This model is created based on different ap-
proaches, often inspired by compiler strategies. Once
the model is complete, they analyse it based on the
knowledge and rules they have of what they are pro-
grammed to and generate a report containing the re-
sults (Chess and West, 2007). However, as these tools
depend on programmed knowledge, they may pro-
duce false positives (FP) by detecting nonexistent vul-
nerabilities and occasionally missing actual vulnera-
bilities, resulting in false negatives (FN). In security,
we know that FP and FN always have a negative effect
on the programmer’s confidence. It is thus crucial to
minimise both and maximise true positives when de-
veloping a static analyser.
Types and Type Systems. Modern software engi-
neering recognises a wide range of formal methods
to ensure the desired and correct behaviour of a sys-
tem. Of all formal methods, type systems are best
established and prevalent (Pierce, 2002). Type sys-
tems, often associated with programming languages,
try to prevent errors from occurring during the exe-
cution of a program by detecting inconsistencies be-
tween types and values at compile time. When de-
signed, they should be easily verifiable and transpar-
ent, which means they must be able to verify if a pro-
gram is typed correctly, and their behaviour should be
predictable. Type systems enable the establishment
of the relationship between the program and the types
used to annotate them (Cardelli, 1996).
Programming languages can be categorised based
on their type systems. PHP is a weakly and dynam-
ically typed language. This means that while each
variable has a specific type, the programmer does not
need to declare their type because it is inferred at run-
time. Due to this dynamic nature and the lack of strict
type enforcement, PHP becomes more susceptible to
potential vulnerabilities, like attackers injecting mali-
cious code in a string to be used in a numeric field.
As previously stated, types function as annota-
tions within computer programs. While different pro-
gramming languages have unique types, certain types,
such as integers, strings, booleans, and others, are
commonly used across multiple languages. Some lan-
guages can feature more complex types like arrays,
objects, or session types, which are especially perti-
nent to this work.
Session Types and FreeST. Session types enable
the specification of heterogenously typed channels,
defining communication protocols between two par-
ties (Vasconcelos, 2012). Session types can be seen as
sequences of input and output operations defining the
messages being exchanged: !T represents the sending
of a value of type T, whereas ?T represents the recep-
tion of a value of type T . Session types can also of-
fer some flexibility in the form of internal or external
choices: +{ℓ : T
ℓ
}
ℓ∈L
represents the internal choice of
a label ℓ, followed by the execution according to T
ℓ
,
whereas &{ℓ : T
ℓ
}
ℓ∈L
offers a set of choices labelled
with ℓ ∈ L and with continuation T
ℓ
. This structure
of sequential operations makes them ideal for mod-
elling protocols in distributed scenarios (Dardha et al.,
2012).
FreeST is an experimental concurrent program-
ming language
4
that uses a core of linear functional
programming and enables the creation of channels for
inter-thread communication. The most notable fea-
ture of FreeST is its robust type system founded on
context-free session types that regulate communica-
tion on channels (Almeida et al., 2019). Context-
free session types (Thiemann and Vasconcelos, 2016)
enable the specification of communication protocols
whose traces are defined by context-free languages,
while regular session types only enable the specifica-
tion of tail recursive protocols. The detail “context-
free” vs “regular” is not important in our setting, so
we will use FreeST for its implementation of session
types (although we could choose any other language
that implements session types
56
).
Table 1 presents the different session types and
primitives within the FreeST language. These types
allow the definition of communication protocols be-
tween threads, with each type being linked to a spe-
cific primitive. FreeST features several communica-
tion primitives: send and receive are used for trans-
mitting and receiving values, select is used to make
choices within the channel, and match is used to align
with the selected option. The close primitive is used
for channel termination, while the wait primitive is
4
https://freest-lang.github.io/
5
https://rss.rd.ciencias.ulisboa.pt/tools/sepi/
6
https://docs.rs/session types/latest/session types/
Towards a SQL Injection Vulnerability Detector Based on Session Types
713