Pipeline - design it top-down; each step unlocks once the one above it is satisfied
Ingestion
ReadyChoose the folder to ingest.
14 files214 pages30.6MB~4m 58s estimated (from 3 past runs)
↓
Filetypes
ReadyWhich file types should be picked up from that folder?
↓
Document parsing
ReadyHow should each selected file type be parsed? PDF, Image, plain/structured text (txt/md/log/ini/cfg), Email (eml), Office documents (docx/pptx), tabular data (csv/tsv/xlsx), structured data (json/xml/yaml/xbrl), Avro, and EDI/X12 are all independent tracks -- toggling one never affects the others. PDF has a third, additive option: OCR the images Native extraction pulls out of the PDF, on top of (not instead of) its native text -- only available once Surya is enabled in the settings panel below. Office/tabular/structured-data/Avro/EDI inputs additionally get docparse's/tableparse's own native per-format output (dataset.json, chunks.jsonl, graph.json, and for Office also media/overlays) written alongside the standard formats -- see pipeline/pdf_pipeline/office_parser.py and tabular_parser.py's module docstrings for exactly what each format gets.
PDF track
Image track
↓
Structure extraction
ReadyBuild a native structural tree + concept/citation graph on top of the parsed content.
↓
Chunking
ReadySplit the structural tree into retrieval-sized chunks (View A, hierarchical). Keyphrase/topology/entity enrichment and concept inventory are optional, model-backed add-ons -- each only checkable once its model is actually available (see the diagnostics badges below).
↓
Embedding
ReadyCompute vector embeddings for each chunk, using either all-MiniLM-L6-v2 (384-dim) or bge-base-en-v1.5 (768-dim, needs a query-instruction prefix -- handled automatically at query time).
↓
Vector store
ReadyStore embeddings in a LanceDB table on disk, shared across every document this run indexes.
↓
Query processing
ReadyEnable the Query tab: type a question, get back the top 10 chunks after Query processing -> Embedding -> Vector search -> Hybrid search (BM25 + reciprocal rank fusion) -> an optional Reranker (bge-reranker-base) pass.
Surya model settings - one choice for the whole run, applies outside the diagram above
Surya's code is Apache-2.0, but the model weights carry a separate,
non-standard license (revenue/funding thresholds, attribution and
share-alike requirements - see
surya-tailored/MODEL_LICENSE).
Nothing in this pipeline invokes the model without this box checked.
Once enabled (and license-acknowledged below), Surya's per-file
options -- including "also OCR extracted images (Tier 3)" -- appear
as checkboxes in the Document parsing step of the diagram above,
not here; this panel only holds the one model/weights/device choice
that applies uniformly to the whole run.
surya-tailored found: yescan load images: yesfull inference ready: yes
Chunking settings - one choice for the whole run; which add-ons run is picked as checkboxes in the Chunking step above
Keyphrases (KeyBERT), topology (HDBSCAN clustering), entities (GLiNER),
and concept inventory are each a separate, optional model -- a
checkbox in the Chunking step above stays disabled until its model's
weights are downloaded and its package installed (see
pipeline/models/README.md). Nothing here is invoked
unless "Build retrieval chunks" is also checked above.
KeyBERT: readyTopology: readyGLiNER: readyConcepts: ready
Retrieval settings - one choice for the whole run; embedding model / LanceDB / reranker are picked as checkboxes in Embedding / Vector store / Query above
Embedding, Vector store, and Query complete the straight-line RAG
pipeline: User query → Query processing → Embedding model
→ Vector search → Hybrid search (BM25 + reciprocal rank
fusion) → Reranker → top 10 chunks. This panel only holds
the device and storage-location knobs; which stage is turned on
(and which embedding model / whether to rerank) is picked as
checkboxes in the diagram above.
all-MiniLM-L6-v2: readybge-base-en-v1.5: readyQwen3-Embedding-0.6B: readymxbai-embed-large-v1: readygte-large-en-v1.5: readybge-reranker-base: readybge-reranker-v2-m3: readymxbai-rerank-large-v2: readyQwen3-Reranker-0.6B: readynli-deberta-v3-base (evidence breakdown): readyLanceDB: ready
Vector snapshots bundle a finished vector store (plus its embedding/
reranker model weights, unless unchecked below) into one uniquely-named,
timestamped folder under pipeline/storage/vector_snapshots/ -- loading
one later points Retrieval settings at its own copy, so a query session
can resume without re-running Ingestion → Embedding at all.
Output formats
Files
20 / 20
OK
20
Errors
0
Elapsed
222s
Process memory
unknown
Peak memory
unknown
Files
| File | Status | Pages | Time | Warnings | Outputs |
|---|---|---|---|---|---|
| docx\COMPASS.docx | ok | 3 | 656ms | 2 | 7 file(s) |
| img\CMVwx.png | ok | 1 | 14.66s | 1 | 8 file(s) |
| img\images (2).png | ok | 1 | 1.90s | 1 | 8 file(s) |
| img\images.png | ok | 1 | 1.91s | 1 | 8 file(s) |
| pdf\1901.03003.pdf | ok | 15 | 10.06s | 1 | 10 file(s) |
| pdf\2408.02509v1.pdf | ok | 14 | 10.51s | - | 10 file(s) |
| pdf\chinese_scan.pdf | ok | 1 | 238ms | 1 | 10 file(s) |
| pdf\issue-336-conto-economico-bialetti.pdf | ok | 2 | 516ms | - | 10 file(s) |
| pdf\lorem.pdf | ok | 1 | 248ms | - | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-01_Magazine-danish.pdf | ok | 32 | 44.60s | 2 | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-02_Invoice.pdf | ok | 1 | 286ms | 1 | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-03_AcademicAbstract.pdf | ok | 2 | 2.85s | - | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-04_Presentation.pdf | ok | 8 | 3.13s | - | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-05_BookChapter-german.pdf | ok | 21 | 11.17s | - | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-06_Brochure.pdf | ok | 2 | 3.12s | - | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf | ok | 32 | 31.90s | 4 | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-09_Scanned.pdf | ok | 82 | 82.16s | 1 | 10 file(s) |
| pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-10_Form.pdf | ok | 1 | 124ms | - | 10 file(s) |
| pptx\pptx_01.pptx | ok | 6 | 393ms | 2 | 7 file(s) |
| xlsx\companies to look out for.xlsx | ok | 2 | 578ms | 2 | 7 file(s) |
Log (C:\Users\cephe\Desktop\UNI Mods\aa_graduated\open-data-loader-pdf-main\open-data-loader-pdf-main\pipeline\logs\run_20260804-185717.log)
2026-08-04 18:57:17 [INFO] ======================================================================
2026-08-04 18:57:17 [INFO] BATCH RUN START run_id=20260804-185717
2026-08-04 18:57:17 [INFO] input_dir=C:\Users\cephe\Desktop\UNI Mods\aa_graduated\open-data-loader-pdf-main\open-data-loader-pdf-main\pipeline\samples
2026-08-04 18:57:17 [INFO] output_dir=C:\Users\cephe\Desktop\UNI Mods\aa_graduated\open-data-loader-pdf-main\open-data-loader-pdf-main\pipeline\sample_output
2026-08-04 18:57:17 [INFO] formats={'json': True, 'markdown': True, 'html': True, 'text': True, 'annotated_pdf': True, 'tagged_pdf': True, 'structure': True, 'native_output': True}
2026-08-04 18:57:17 [INFO] discovered 20 PDF/image file(s)
2026-08-04 18:57:17 [INFO] [1/20] START docx\COMPASS.docx (rss=unknown)
2026-08-04 18:57:17 [INFO] [1/20] OK docx\COMPASS.docx pages=3 656ms rss=unknown (delta 0B) warnings=2
2026-08-04 18:57:17 [WARNING] [docx\COMPASS.docx] generate_pdf/generate_tagged_pdf are not supported for office-document inputs (no PDF page geometry to overlay onto); skipped.
2026-08-04 18:57:17 [WARNING] [docx\COMPASS.docx] native docx output written to 'C:\\Users\\cephe\\Desktop\\UNI Mods\\aa_graduated\\open-data-loader-pdf-main\\open-data-loader-pdf-main\\pipeline\\sample_output\\docx\\COMPASS' (1 sections, 40 blocks).
2026-08-04 18:57:17 [INFO] [2/20] START img\CMVwx.png (rss=unknown)
2026-08-04 18:57:32 [INFO] [2/20] OK img\CMVwx.png pages=1 14661ms rss=unknown (delta 0B) warnings=1
2026-08-04 18:57:32 [WARNING] [img\CMVwx.png] generate_pdf/generate_tagged_pdf are not supported for image inputs (Surya-derived bounding boxes are pixel coordinates, not PDF points); skipped.
2026-08-04 18:57:32 [INFO] [3/20] START img\images (2).png (rss=unknown)
2026-08-04 18:57:34 [INFO] [3/20] OK img\images (2).png pages=1 1902ms rss=unknown (delta 0B) warnings=1
2026-08-04 18:57:34 [WARNING] [img\images (2).png] generate_pdf/generate_tagged_pdf are not supported for image inputs (Surya-derived bounding boxes are pixel coordinates, not PDF points); skipped.
2026-08-04 18:57:34 [INFO] [4/20] START img\images.png (rss=unknown)
2026-08-04 18:57:36 [INFO] [4/20] OK img\images.png pages=1 1908ms rss=unknown (delta 0B) warnings=1
2026-08-04 18:57:36 [WARNING] [img\images.png] generate_pdf/generate_tagged_pdf are not supported for image inputs (Surya-derived bounding boxes are pixel coordinates, not PDF points); skipped.
2026-08-04 18:57:36 [INFO] [5/20] START pdf\1901.03003.pdf (rss=unknown)
2026-08-04 18:57:46 [INFO] [5/20] OK pdf\1901.03003.pdf pages=15 10059ms rss=unknown (delta 0B) warnings=1
2026-08-04 18:57:46 [WARNING] [pdf\1901.03003.pdf] Could not rasterize page 0 of '1901.03003' for its bounding-box overlay (pypdfium2 failed to render the page); skipped.
2026-08-04 18:57:46 [INFO] [6/20] START pdf\2408.02509v1.pdf (rss=unknown)
2026-08-04 18:57:56 [INFO] [6/20] OK pdf\2408.02509v1.pdf pages=14 10509ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:57:56 [INFO] [7/20] START pdf\chinese_scan.pdf (rss=unknown)
2026-08-04 18:57:57 [INFO] [7/20] OK pdf\chinese_scan.pdf pages=1 238ms rss=unknown (delta 0B) warnings=1
2026-08-04 18:57:57 [WARNING] [pdf\chinese_scan.pdf] Could not rasterize page 0 of 'chinese_scan' for its bounding-box overlay (pypdfium2 failed to render the page); skipped.
2026-08-04 18:57:57 [INFO] [8/20] START pdf\issue-336-conto-economico-bialetti.pdf (rss=unknown)
2026-08-04 18:57:57 [INFO] [8/20] OK pdf\issue-336-conto-economico-bialetti.pdf pages=2 516ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:57:57 [INFO] [9/20] START pdf\lorem.pdf (rss=unknown)
2026-08-04 18:57:57 [INFO] [9/20] OK pdf\lorem.pdf pages=1 248ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:57:57 [INFO] [10/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-01_Magazine-danish.pdf (rss=unknown)
2026-08-04 18:58:42 [INFO] [10/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-01_Magazine-danish.pdf pages=32 44599ms rss=unknown (delta 0B) warnings=2
2026-08-04 18:58:42 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-01_Magazine-danish.pdf] pdf_pipeline._vendor.pdfminer_six.cmapdb: Ignoring (part of) ToUnicode map because the PDF data does not conform to the format. This could result in (cid) values in the output. The start and end byte have different lengths.
2026-08-04 18:58:42 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-01_Magazine-danish.pdf] Could not rasterize page 0 of 'PDFUA-Ref-2-01_Magazine-danish' for its bounding-box overlay (pypdfium2 failed to render the page); skipped.
2026-08-04 18:58:42 [INFO] [11/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-02_Invoice.pdf (rss=unknown)
2026-08-04 18:58:42 [INFO] [11/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-02_Invoice.pdf pages=1 286ms rss=unknown (delta 0B) warnings=1
2026-08-04 18:58:42 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-02_Invoice.pdf] Could not rasterize page 0 of 'PDFUA-Ref-2-02_Invoice' for its bounding-box overlay (pypdfium2 failed to render the page); skipped.
2026-08-04 18:58:42 [INFO] [12/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-03_AcademicAbstract.pdf (rss=unknown)
2026-08-04 18:58:45 [INFO] [12/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-03_AcademicAbstract.pdf pages=2 2848ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:58:45 [INFO] [13/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-04_Presentation.pdf (rss=unknown)
2026-08-04 18:58:48 [INFO] [13/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-04_Presentation.pdf pages=8 3135ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:58:48 [INFO] [14/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-05_BookChapter-german.pdf (rss=unknown)
2026-08-04 18:58:59 [INFO] [14/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-05_BookChapter-german.pdf pages=21 11173ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:58:59 [INFO] [15/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-06_Brochure.pdf (rss=unknown)
2026-08-04 18:59:02 [INFO] [15/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-06_Brochure.pdf pages=2 3118ms rss=unknown (delta 0B) warnings=0
2026-08-04 18:59:02 [INFO] [16/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf (rss=unknown)
2026-08-04 18:59:34 [INFO] [16/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf pages=32 31895ms rss=unknown (delta 0B) warnings=4
2026-08-04 18:59:34 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf] pdf_pipeline._vendor.pdfminer_six.pdfinterp: Cannot set stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported
2026-08-04 18:59:34 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf] pdf_pipeline._vendor.pdfminer_six.pdfinterp: Cannot set stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported
2026-08-04 18:59:34 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf] pdf_pipeline._vendor.pdfminer_six.pdfinterp: Cannot set stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported
2026-08-04 18:59:34 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-08_BookChapter.pdf] pdf_pipeline._vendor.pdfminer_six.pdfinterp: Cannot set stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported
2026-08-04 18:59:34 [INFO] [17/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-09_Scanned.pdf (rss=unknown)
2026-08-04 19:00:57 [INFO] [17/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-09_Scanned.pdf pages=82 82158ms rss=unknown (delta 0B) warnings=1
2026-08-04 19:00:57 [WARNING] [pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-09_Scanned.pdf] Could not rasterize page 0 of 'PDFUA-Ref-2-09_Scanned' for its bounding-box overlay (pypdfium2 failed to render the page); skipped.
2026-08-04 19:00:57 [INFO] [18/20] START pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-10_Form.pdf (rss=unknown)
2026-08-04 19:00:57 [INFO] [18/20] OK pdf\pdfua-1-reference-suite-1-1\PDFUA-Ref-2-10_Form.pdf pages=1 124ms rss=unknown (delta 0B) warnings=0
2026-08-04 19:00:57 [INFO] [19/20] START pptx\pptx_01.pptx (rss=unknown)
2026-08-04 19:00:57 [INFO] [19/20] OK pptx\pptx_01.pptx pages=6 393ms rss=unknown (delta 0B) warnings=2
2026-08-04 19:00:57 [WARNING] [pptx\pptx_01.pptx] generate_pdf/generate_tagged_pdf are not supported for office-document inputs (no PDF page geometry to overlay onto); skipped.
2026-08-04 19:00:57 [WARNING] [pptx\pptx_01.pptx] native pptx output written to 'C:\\Users\\cephe\\Desktop\\UNI Mods\\aa_graduated\\open-data-loader-pdf-main\\open-data-loader-pdf-main\\pipeline\\sample_output\\pptx\\pptx_01' (6 sections, 20 blocks).
2026-08-04 19:00:57 [INFO] [20/20] START xlsx\companies to look out for.xlsx (rss=unknown)
2026-08-04 19:00:58 [INFO] [20/20] OK xlsx\companies to look out for.xlsx pages=2 578ms rss=unknown (delta 0B) warnings=2
2026-08-04 19:00:58 [WARNING] [xlsx\companies to look out for.xlsx] generate_pdf/generate_tagged_pdf are not supported for tabular inputs (no PDF page geometry to overlay onto); skipped.
2026-08-04 19:00:58 [WARNING] [xlsx\companies to look out for.xlsx] native xlsx output written to 'C:\\Users\\cephe\\Desktop\\UNI Mods\\aa_graduated\\open-data-loader-pdf-main\\open-data-loader-pdf-main\\pipeline\\sample_output\\xlsx\\companies to look out for' (549 chunks, views={'metadata': 2, 'column': 2, 'row': 159, 'window': 79, 'hierarchical': 148, 'graph': 159}).
2026-08-04 19:00:58 [INFO] ----------------------------------------------------------------------
2026-08-04 19:00:58 [INFO] BATCH RUN DONE run_id=20260804-185717 total=20 ok=20 error=0 duration=221028ms peak_rss=unknown
2026-08-04 19:00:58 [INFO] summary written to C:\Users\cephe\Desktop\UNI Mods\aa_graduated\open-data-loader-pdf-main\open-data-loader-pdf-main\pipeline\logs\run_20260804-185717.summary.json
Query - the final step of the pipeline: try a retrieval query against whatever this run's Vector store has indexed
User query→Query processing→Embedding model→Vector search→Hybrid search→Reranker→Top 10 chunks
10 result(s) for "comprehensive vulnerability dataset" (reranked with bge-reranker-base). Logged to C:\Users\cephe\Desktop\UNI Mods\aa_graduated\open-data-loader-pdf-main\open-data-loader-pdf-main\pipeline\storage\query_logs\qa_20260804.log
#1rerank 0.237
Attackstringselection.
pick n best(P, n, D , 1 )
1 Procedure vul vul
P
Input: ,originalattackstringpool
n,numberofelementstokeep
Dvul,vulnerabilitydataset
1vul,vulnerabilityjudge
Output: newpoolwith n attackstrings
= []
2 for σ ∈P do
adv
3 construct G usingtheattackstring σ
adv
4 v = vul ratio(G ) w.r.t. Dvul and 1vul
5 V.append(v)
n P V
6
return bestelementsfrom accordingto
7
8
9
Attackstringmutation.
mutate(σ)
Procedure
Input: σ,originalattackstring
nσ,attackstringlength
Output: mutatedattackstring
= T.string to tokens(σ)
=sample([1,nσ])
=sample without replacement([0,nσ −1], n)
for i ∈I do
t[i] = T.random token from vocab()
return T.tokens to string(t)
tokenizer train
attackstringsaccordingtoourtrainingset D andonly
vul
keepthesestringsinthepool(Line3).Theimplementation
n best
willbediscussedlaterinthissection.
Next,weproceedtothemainoptimizationloop(Line4
toLine8).Withineachloopiteration,westartthepoolof
candidatesolutionsfromthepreviousiteration,denotedas
mutate
.AtLine5,the functioniscalledtorandomly
new
mutateeachcandidatestring,resultinginanewpool P .
mutate
willbepresentedlaterinthissection.
Then,atLine6,wemergethepreviouspoolandthemutated
pick n best
pool.Next,weinvokethe functiononthe
train
D toselectthetop nP candidatesfrom
vul
themergedpool,whicharethensetasthepoolforthe
subsequentiteration.
Afterthemainoptimizationloop,westillmaintaina
finalpoolofattackstringsthatachievehighvulnerability
pick n best
train
ratioonthetrainingset D .The function
vul
istheninvokedtoidentifythemosteffectiveattackstring
val
onthevalidationset D ,whichischosenasthefinal
vul
outcome.Thefinalstringisusedtoconstructthemalicious
codecompletionengine Gadv,whichachievestheattacker’s
objectivesdefinedinSection3.1.
InseveralstepsofAlgorithm1,werelyonaselection
pick n best mutate
andamutationfunction .
length
Wepresentthedetailsofthesetwofunctionsintheremaining
pick n best
Thefunction isusedtoselect
TABLE1:OverviewoftheCWEstargetedinthispaperandthesizeofthecorrespondingvulnerabilitydatasets.
CWELanguageTop-25CWERankAvgLoCMaxLoC
020:ImproperInputValidationPython#61622
022:PathTraversalPython#81428
077:CommandInjectionRuby#16919
078:OSCommandInjectionPython#51530
079:Cross-siteScriptingJavaScript#21927
089:SQLInjectionPython#31932
090:LDAPInjectionPython–2333
131:MiscalculationofBufferSizeC/C++–2235
193:Off-by-oneErrorC/C++–2654
326:WeakEncryptionGo–3475
327:FaultyCryptographicAlgorithmPython–1434
416:UseAfterFreeC/C++#41822
476:NULLPointerDereferenceC/C++#122268
502:DeserializationofUntrustedDataJavaScript#151418
787:Out-of-boundsWriteC/C++#12152
943:DataQueryInjectionPython–2531
the n top-performingcandidateattackstringsfromagiven
poolofstrings.Onahighlevel,thisfunctionestimateshow
ofteneachattackstringcausesthemaliciouscompletion
enginetogeneratevulnerablecodeforagivendataset,and
finallyreturnonlythe n candidatesthatleadtothehighest
ratioofinsecurecompletions.Thisfunctionplaysacrucial
roleinanexploitationprocessbyensuringtheprioritization
ofthemosteffectiveattackstrings.
Wepresentthedetailsof
pick n best
inAlgorithm2.
#2rerank 0.149
| Algorithm1: | Attackstringoptimization. | Algorithm2: |
| --- | --- | --- |
| | Procedure optimize( D train vul , D val vul , 1 vul , n P , n σ ) 1 | |
| P | Input: D train vul ,trainingdataset D val vul ,validationdataset 1 vul ,vulnerabilityjudge n P ,attackstringpoolsize n σ ,attackstringlength Output: thefinalattackstring = init pool ( n σ , D train vul ) //Section4.2 2 3 | V |
| P | = pick n best ( P , n P , D train vul , 1 vul ) 4 | |
| | repeat 5 | |
| | P new = [ mutate ( σ , n σ ) for σ in P ] 6 | |
| | P new = P new + P new train 7 | |
| | P = pick n best ( P , n P , D vul , 1 vul ) | |
| | for afixednumberofiterations val | |
| | return pick n best ( P , 1 , D vul , 1 vul ) | Algorithm3: |
| | | |
| | InversionInitialization TheINSECattackworksbyinsert- ingacommentsuchthatinsecurecodegetsgeneratedbythe underlyingcompletionengine.Toinitializethecomment,we 1 2 | t |
| | nowaddresstheinverseproblem:wegeneratethecomment byfeedingtheenginewithinsecurecode.Thisexploitsthe 3 4 | n I |
| | engine’scapabilityinunderstandingtherelationshipbetween commentsandcodeinitsowndistribution. 5 6 | |
| | | |
| | 7 | |
| | RandomInitialization Finally,weincreasethediversity | |
| | | |
| | ofourinitializationbygeneratingrandomattackstrings.We achievethisbyrandomlysamplingtokensfromtheattacker’s T andconcatenatingthemintostrings. 4.3.AttackStringOptimization of | pick |
| theattack. Overview | Afterproducingasetofinitialattackstrings,wecontinue byoptimizingthesestringstoenhancetheeffectivenessof Onahighlevel,ouroptimizationalgorithm maintainsaconstant-sizedpoolofattackstrings,randomly mutatesthem,andkeepsthebest-performingonesinthe P | Thedetailsof |
| | pool.NotethatourattacktemplatediscussedinSection4.1 ensuresthattheattackintroducesonlyminimalchangetothe completioninputs,thuspreservingfunctionalcorrectnessas comparedtotheoriginalcodecompletionengine.Therefore, ouroptimizationprocedurefocusessolelyonincreasingthe vulnerabilitylevel. | trainingset |
| | WeprovideINSEC’sattackstringoptimizationprocedure inAlgorithm1.Thealgorithmtakesasinputtwodatasets ofsecurity-sensitivecompletiontasks,atrainingset D train vul andavalidationset D val vul .AtLine2,wefirstinitialize thepoolofattackstrings,usingthestrategiesdescribedin Section4.2.Weensurethattheinitializationonlyhasaccess tothetrainingset D train vul .Consideringthatwesetafixed function | |
| n leveragethe | σ fortheattackstrings,wetruncateeachinitialized stringattheendtoconformtothisconstraint.Thenumber ofinitializedattackstringscanexceedourpoolsize n P ,we pick n best functiontoselectthebest n P Selection | ofthissection. |
#3rerank 0.053
88
76
64
52
40
overtheeffective-
func rate@10
87
79
71
63
55
00.2 0.4 0.60.81.0 00.2 0.4 0.60.81.0
Optimizationtemperature Evaluationtemperature
Figure10:AttackingStarCoder-3BwithINSECacross
varyingoptimizationtemperaturesforafixedevaluation
temperatureof 0.4.WhileINSECsucceedsatanytempera-
ture,thestrongestattacksareinlowerranges(0.2−0.4).
Figure11:Resultsonvaryingevaluationtemperaturesof
attackingStarCoder-3BwithafixedINSECattack.Our
attackisstrongeronlowertemperatures,whichisalsoat
whichmostcodecompletionenginesareutilized.
highervulnerabilityratioandsimilarfunctionalcorrectness,
ascomparedtothescenarioswhereeachcomponentisused
individually.Thisisbecausetheinitializationprovidesa
goodstartingpoint,whichtheoptimizationprocedurethen
buildsupontoderivethemosteffectiveattackstring.
AttackStringInitialization Now,wediveintothe
investigatingtheeffectivenessofourdiverseinitialization
schemes.InSection4.2,weintroducefivedifferentinitial-
izationschemes: TODO, security-criticaltoken, sanitizer,
inversion,and randominitialization.Asnotallofthese
initializationschemesareapplicableforeachvulnerability,
weconstructinitialpoolsdependingonthetargetCWE.
Nonetheless,inFigure7,weexaminetheimportanceofeach
ofourinitializationschemebymeasuringtheshareoftarget
vulnerabilitieswhereourfinalattackstringfoundbyINSEC
stemsfromagiveninitializationscheme.Firstofall,wecan
observethatinthemajorityofthecases,security-critical
tokeninitializationprovestobethemosteffective.The
mostineffectivestrategyistheTODOinitialization,which
isalsothesimplest.Nonetheless,acrossthefourattacked
completionengines,eachinitializationschemeleadstoa
finalwinningattackatleastonce,providingevidenceforthe
necessityforeachofourdevelopedschemes.
AttackStringOptimization Next,weexaminevarious
designchoicesinourattackoptimizationprocedure,as
discussedinSection4.3.
PoolSize Akeyaspectofourattackalgorithmisthesize
nP ofthepool P thatcontainsattackstringcandidates.
Recallthatwefixthenumberoftotaliterationsasingle
attackmayexpense.Assuch, nP controlsthegreedinessof
ouralgorithm;insmallerpoolslesscandidatesareoptimized
formoresteps,whileinalargerpoolmorediversecandidates
areoptimizedforlesssteps.Tounderstandtheeffectofthis
ontheattackperformance,weexperimentwithpoolsizes
between 1 and 160,andshowourresultsinFigure9.Wecan
clearlyobservethatattacksthatareeithertoogreedy(i.e.,
nP toosmall)andattacksthatover-favorexplorationand
assuchareessentiallyrandom(i.e., nP toolarge)produce
weakattackswithalowvulnerabilityratio.Naturally,atthe
sametime,suchweakattackspreservemoreofthefunctional
correctnessoftheattackedcompletionengine.Forourfinal
attack,wechose nP =20,whichprovidesafavorable
tradeoffbetweengreedinessandexplorativeness,reaching
thehighestattackimpactwhilestillretainingreasonable
functionalcorrectness.Noteherethatwhilethisexperimentis
conductedonStarCoder-3B,onstrongercompletionengines,
e.g.,GPT-3.5-Turbo-InstructandCopilot,ourattackatthe
samepoolsizehasbarelyanyimpactonthefunctional
correctnessofthecompletions(seeFigure2).
TokenizerAccess Akeyelementinouroptimization
processistheattacktokenizer T,underwhichthetoken-
levelmutationsareperformed.Recallthatunderourthreat
modelweassumethattheattackerdoesnothaveaccess
tothetokenizerofthetargetcompletionengine,andas
suchhastouseaproxytokenizeras T.InFigure6,we
exploretheimpactofthisrestriction.Wemeasuretheelicited
vulnerabilityratiobytheattackandtheattack’simpact
onthefunctionalcorrectnessofthegeneratedcompletions
acrossfourtokenizers:tokenizationperunicodecharacters;
GPT-2tokenizer,atokenizerforageneral-purposemodel;
CodeQwentokenizer,acode-specifictokenizer;andStar-
Codertokenizer,thetokenizerofthetargetmodel.Wecan
observethattheunicodetokenizerproducestheweakest
attacks,whileCodeQwenandStarCodertokenizersproduce
similarresultsintermsofvulnerabilityratio,withthetarget
modeltokenizerpreservingthefunctionalcorrectnessbetter.
Assuch,weconcludethatusingaproxytokenizermostly
onlyaffectsthepreservedfunctionalcorrectness,which
losesitsimportanceaswemoveontostrongercompletion
engines,wherefunctionalcorrectnessisstronglypreserved
evenunderourcurrentattackemployingtheproxytokenizer
ofCodeQwen(seeFigure2forreference).
OptimizationTemperature Recallthat,atLine5ofAlgo-
rithm2,weevaluatethevulnerabilityratioofamalicious
completionengine,eitheronthetrainingset
val
train
D
vul
or
thevalidationset D .Thisassessmentrequiressampling
vul
fromthetargetedengine.Thetemperatureparameterplays
acriticalroleincontrollingthediversityofthesampled
completions.Highertemperaturesincreasediversity,and
temperaturescloseto 0 leadtoamoredeterministicoutput.
Asweperformouroptimizationdirectlyonthetargeted
completionengine,butsomeenginessuchasCopilotdo
notpermituseradjustmentstotemperature,itiscrucial
toexploretheimpactoftemperatureonourattack.In
Figure10,weexploretemperaturesrangingfrom
1.0 duringoptimizationandmeasuretheresultingattacks’
vulnerabilityratioandfunctionalcorrectness.Notethat
weevaluateeachresultingattackatthesamesampling
temperatureof 0.4
0 to
forcomparability.Firstofall,weobserve
thatourattackachievesanon-trivialvulnerabilityratioat
anyoptimizationtemperature,whichimpliesthatevenAPIs
wherethisparametercannotbesetarevulnerabletoINSEC.
Next,wecanseethatthereisanidealrangeoftemperature
values(0.2−0.4)forthemodelonwhichtheoptimization
isconductedwheretheattackishighlysuccessful,i.e.,it
achieveshighvulnerabilityratiowhileretainingagood
amountoffunctionalityinthecompletions.Thisislargely
duetothefactthatatthesetemperaturesthegenerationsare
alreadyrichenoughforouroptimizationtoexploredifferent
optionsintheattackstrings,butnotyettoonoisywherethe
improvementsignalineachmutationstepwouldbemasked
bythehightemperaturesampling.Basedonthisinsight,
wepickatemperatureof 0.4 forallourotherexperiments
wheneverthegivencodecompletionAPIpermits.
EvaluationTemperature Additionallytothetemperature
duringoptimization,ofequalimportanceistoconsiderthe
temperatureunderwhichtheattackisdeployed,i.e.,the
temperatureduringevaluation.Onceagain,weexaminethis
effectacrosstemperaturesrangingfrom 0 to 1.0 inFigure11.
Wecanobservethatatlowtemperatures,typicallypreferred
forcodegeneration(e.g., 0.0−0.4),INSECachievesahigh
vulnerabilityratioandfunctionalcorrectness.Astemperature
increases,thevulnerabilityratiooftheattackdecreases,
asalsoobservedin[15].However,thevulnerabilityratio
stillremainshigh,indicatingthattheattackcontinuesto
poseaseriousthreat.Intermsoffunctionalcorrectness,
func rate@10 isamorerelevantmetricforhightemperature
#4rerank 0.051
Givenanattackstring σ intheinputpool P (Line3),we
adv
firstconstructamaliciouscompletionengine
σ
G with
(Line4).Then,atLine5,wecomputethevulnerability
scoreof
adv
G usingEquation(3)w.r.t.theinputdataset Dvul
andvulnerabilityjudgementfunction 1vul.Wesample 16
adv
completionsforeachtaskwhencomputingvul ratio(G
).
ThesevulnerabilityscoresarecollectedinanarrayV (Line6).
Finally,inLine7,wepickthe n bestattackstringsaccording
thevulnerabilityscores V andreturnthem.
Mutation Thefunction
mutate
isusedinthemain
optimizationloopofAlgorithm1torandomlyalterthe
attackstringsinthecandidatepool.Itisanimportantstep
forINSEC’soptimizationalgorithmtoexplorenewstrings,
enhancingtheeffectivenessofthefinalattackstring.
Theimplementationof
mutate
isillustratedinAlgo-
rithm3.First,usingtheattacker’stokenizer T,weconvert
theinputattackstring σ toanarrayoftokens t (Line2).
Notethattocomplywiththeblack-boxassumptionmade
inSection3,werelyonanattacktokenizerthatdoesnot
necessarilymatchthatoftheoriginalcompletionengine.In
Section5.3,weshowtheimpactoftokenizerchoicesonthe
effectivenessoftheattack.Next,inLine3,weuniformly
samplethenumberoftokens n thatwillbemutatedin σ.
Here,weexcludethepossibilityofnotperturbinganyofthe
tokens(i.e.,wealwayssample n ≥ 1),astheunperturbed
stringwillalwaysbeconsideredintheselectionstepbefore
thenextroundofmutations(seeLine6inAlgorithm1).
Then,giventhenumberoftokenstobemutated n,inLine4,
werandomlysample(withoutreplacement)aset I of n
positionindicesin t tomutate.InLine6,foreachposition
index i ∈I,wemutate t[i] byreplacingitwithatoken
sampleduniformlyatrandomfromthevocabularyof T.
Finally,atLine7,weconvertthemutatedtokensbacktoa
stringandreturnit.
#5rerank 0.031
4.1.Datasets
IIIT5K-Words(IIIT5K) [32]contains3000
croppedwordimagesfortesting.Everyimagehas
a50-wordlexiconanda1000-wordlexicon.The
lexiconconsistsofagroundtruthandsomerandomly
pickedwords.
StreetViewText(SVT) [48]wascollectedfrom
theGoogleStreetView,consistingof647word
images.Manyimagesareseverelycorruptedbynoise
andblur,orhaveverylowresolutions.Eachimageis
associatedwitha50-wordlexicon.
ICDAR2003(IC03) [31]contains251sceneim-
agesthatarelabeledwithtextboundingboxes.Forfair
comparison,wediscardedimagesthatcontainnon-
alphanumericcharactersorthosehavelessthanthree
characters,followingWang,Babenko,andBelongie
[48].Thefiltereddatasetcontains867croppedimages.
Lexiconscompriseofa50-wordlexicondefinedby
Wangetal.[48]anda“fulllexicon”.Thelatterlexicon
combinesalllexiconwords.
ICDAR2013(IC13) [25]inheritsmostofits
samplesfromIC03.Itcontains1015croppedtext
images.Nolexiconisassociatedwiththisdataset.
SVT-Perspective(SVT-P) [35]contains645
croppedimagesfortesting.Imagesareselectedfrom
side-viewanglesnapshotsinGoogleStreetView.
Therefore,mostimagesareperspectivedistorted.
Eachimageisassociatedwitha50-wordlexiconand
afulllexicon.
CUTE80 [37]contains80high-resolutionimages
takeninnaturalscenes.Itwasspecificallycollected
forevaluatingtheperformanceofcurvedtextrecog-
nition.Itcontains288croppednaturalimagesfor
testing.Nolexiconisassociatedwiththisdataset.
ICDAR2015(IC15) [24]contains2077cropped
imagesincludingmorethan200irregulartext.No
lexiconisassociatedwiththisdataset.
4.2.ImplementationDetails
Network: DetailsabouttheMORNandtheASRN
ofMORANaregiveninTable1andTable2respec-
tively.ThenumberofhiddenunitsofGRUin
thedecoderis 256.TheASRNoutputs37classes,
including26letters,10digitsandasymbolstanding
for“EOS”.
TrainingModel: AsstatedinSection3.4,the
trainingoftheMORANisguidedbyacurriculum
learningstrategy.Thetrainingdataconsistsof8-
millionsyntheticimagesreleasedbyJaderbergetal.
[20]and6-millionsyntheticimagesreleasedbyGupta
etal.[15].Noextradataisused.Wedonot
useanygeometric-levelorpixel-levellabelsinour
experiments.Withoutanyfine-tuningforeachspecific
dataset,themodelistrainedusingonlysynthetictext.
WithADADELTA[55]optimizationmethod,weset
learningrateto 1.0 atthebeginninganddecreasedit
to 0.01
strategy.Followingthesimilarsettingsin[28],we
foundthatadecreasedlearningratecontributesto
betterconvergence.Thebatchsizewassetto64.We
trainedthemodelfor600,000,20,000and300,000
iterationsrespectivelyinthreestagesofthecurriculum
inthethirdstageofthecurriculumlearning
learningstrategy.Thetrainingtotallyconsumed30
hours.
Implementation: Weimplementedourmethod
undertheframeworkofPyTorch[34].CUDA8.0
andCuDNNv7backendsareusedinourexperiments
soourmodelisGPU-accelerated.Alltheimages
areresizedto 32 × 100.WithanNVIDIAGTX-
#6rerank 0.027
100
8287
65
75
50
29
25
100 98
100
75
50
25
100
77
73
75 67 66
50
25
0
With Without
comment comment
(b)Differentattacktype.
)achievedby(a)differentinsertionpositions
≥ 25%),
.
func
First,weexamineourchoiceofthe
AsdiscussedinSection4.1,ourattack
asacommentinthelineabove
isexpected.Asaresult,theinput
sremainsunchanged.We
ofCodeLlama-7Baveragedacrossall16vulnerabilitiesis analyzethischoiceofattackpositioninFigure4a,comparing
adv adv adv adv
vul ratio(G ) func rate@1(G ,G) vul ratio(G ) func rate@1(G ,G)
#7rerank 0.020
| | 100 97979495 |
| --- | --- |
| | 60636670 7375 |
| | |
| | 31 26 |
| | 62 0030 10 |
| 0 | CWE-131-cppCWE-943-pyCWE-787-cppCWE-327-pyCWE-502-jsCWE-089-pyCWE-416-cppCWE-476-cpp 98 888992929696100100 969994 929491 |
| | 84 |
| | 60 |
| | 14 16 |
| | 00 2 |
| 0 | CWE-022-pyCWE-090-pyCWE-078-pyCWE-077-rbCWE-193-cppCWE-079-jsCWE-326-goCWE-020-py Figure3:BreakdownofourINSECattackappliedonCodeLlama-7Boverdifferentvulnerabilities. vul ratio ( G adv ) func rate@ 1( G adv , G ) |
| | 96 97 |
| | 73 75 77 78 69 100 |
| | 49 5451 46 75 |
| | 33 50 |
| | 911 25 |
| | Line above Startof prefix Startof sameline Endof prefix Startof suffix Line below Endof suffix (a)Differentattackposition. 0 Figure4:Vulnerabilityratio(vul ratio)andfunctionalcorrectness(func rate@ 1 |
| | fortheattackstring σ and(b)if σ isformattedasacomment.Ourdesignchoices(LineaboveandWithcomment)achieve thebesttradeoffbetweenvulnerabilitylevelandfunctionalcorrectness. vulnerablecode 73% and 67% ofthetime,respectively, withoutvirtuallyanyimpactoncodefunctionality.Thisresult isespeciallyconcerning,asinpracticestrongerengineswill bepreferredbyprogrammers,which,byproducinghighly functionalyetvulnerablecodeunderourattack,couldlead tomoresuccessfulattackswheretheprogrammeraccepts theengine’ssuggestions. BreakdownPerCWE InFigure3,weshowourmain resultsonCodeLlama-7Bbrokendownpervulnerability.We orderthevulnerabilitiesbythefinalvulnerabilityscoreof INSEC.Firstofall,weobservethatourattackmanagesto increasethevulnerabilityratioofthegeneratedprograms acrossallvulnerabilities,exceptforCWE-079-jsandCWE- 020-pywheretheoriginalcompletionenginealreadyhasa highvulnerabilitylevel.Inparticular,ourattackmanages totriggeravulnerabilityratioofover 90% onmorethana thirdofallexaminedCWEs.Remarkably,inseveralcases INSECmanagestotriggersuchhighattacksuccessrates eventhoughthebasemodelhadavulnerabilityratioof closetozero.Further,weobservethatwhilethefunc rate@ 1 89% (seeFigure2),thisaverageiscomposedofabimodal distribution.Attackstargetingcertainvulnerabilitieshave largerrelativeimpactonfunctionalcorrectness( whileothershavealmostnoimpact. 5.3.AblationStudies Next,wepresentdetailedablationstudiesovervarious designchoicesandhyperparametersofINSEC.Wealways varyonedesignchoiceorhyperparameterandkeeptheother configurationsfixed.Unlessstatedotherwise,wealways focusonattackingStarCoder-3Bandpresentresultsonthe validationdatasets, D val vul and D val AttackTemplate attacktemplate,whichconsistsofanattackposition,the attackformat,andthenumberoftokensintheattackstring. Attackposition insertstheattackstring σ wherethecompletion c prefix p ismodifiedwhilethesuffix |
#8rerank 0.008
SlobodanJenko,JingxuanHe,NielsM¨undler,MarkVero,andMartinVechev
sjenko@ethz.ch,
ETHZurich,Switzerland
{jingxuan.he,niels.muendler,mark.vero,martin.vechev}@inf.ethz.ch
languagemodels,havedemonstratedimpressivecapabilitiesto
4
generatefunctionallycorrectcodebasedonsurroundingcontext.
2
Asthesetoolsareextensivelyusedbymillionsofdevelopers,it
0
iscrucialtoinvestigatetheirsecurityimplications.Inthiswork,
2
wepresentINSEC,anovelattackthatdirectscodecompletion
g
enginestowardsgeneratingvulnerablecode.Inlinewithmost
u
commercialcompletionengines,suchasGitHubCopilot,INSEC
#9rerank 0.005
| vulnerableasanattackercanuseittoaccessfilesoutside oftheintendeddirectory.Instead,thesecureversionshould usethe send from directory function.Inthiscase, |
| --- |
| ourinitializationcreatesanattackstring“ usesend file ” |
| withagoodvulnerabilityratioof 65% forGPT-3.5-Turbo- Instruct.Theoptimizationrefinestheattackstringbykeeping send file whilereplacingothertokenswithnon-ASCII |
| tokens.Asaresult,theattackstrengthisincreasedto 96% . Thenewtokensintheoptimizedattackstringdonothave ahuman-interpretablemeaninganditwouldbedifficultto obtainthesetokenswithoutoptimization. |
| @web_app.route('/js/<f:f>') def send_js_files(f): js_dir="frontend/js" print (f[:-4]) # { attack string σ } return flask.send_file(os.path.join(js_dir,f)) @web_app.route("/") def main_page(): return flask.render_template("index.html") |
| Finally,wedemonstratethathowouroptimizationsub- stantiallyimprovesarandomlyinitializedattackstring. TheexampleinC/C++containsaCWE-131vulnerability: IncorrectCalculationofBufferSize.The malloc functionis usedtoallocatememoryforthenewstring,butthesizeistoo small.Thisleavesthecodesusceptibletoabufferoverflow attack,whichcouldleadtoanythingfromprogramcrashesto maliciouscodeexecution.Initializationcreatesonlyattacks withalowvulnerabilityratioof ≤ 14% forStarCoder-3B. Thefinalattackstringoriginatesfromarandomlyinitialized stringwithnon-ASCIItokensandbringsthevulnerability ratioupto 63% .Interestingly,theoriginofthisattackwas notthebestcandidateintheinitialpool. |
| char *append_exclamation( constchar *input){ char *new_input; // { attack string σ } new_input=( char *)malloc(strlen(input)); if (new_input==NULL){ fprintf(stderr,"Failedtoallocatememory"); exit(1); } strcpy(new_input,input); new_input[strlen(input)]='!'; return new_input; } |
#10rerank 0.004
Inthissection,wepresentourthreatmodel,detailing
theattacker’sgoalandknowledge.
3.1.Attacker’sGoal
Onahighlevel,theattackerseekstoconstructa
adv
maliciouscodecompletionengine G thatfrequently
suggestsinsecurecode.Ifthesesuggestionsareadopted,they
couldintroducemajorvulnerabilitiesintotheprogrammer’s
codebase,compromisingitsintegrity.Atthesametime,to
maintainstealthandavoiddetection,theattackerneedsto
ensurethatthegeneratedcoderemainsfunctionallycorrect.
Thisiscrucialnotonlyforpreservingtheprogrammer’s
trustinthecodecompletiontoolbutalsoforincreasingthe
likelihoodthattheprogrammerwillaccepttheinsecurecode
suggestions[15].
Toaccomplishthis,theattackerselectsanexisting
(black-box)completionengine
adv
G anddevisesafunction
adv
f : S×S→S×S.Thisfunctionf modifiestheoriginal
′ ′
inputpair (p,s) intoanadversarialpair (p ,s ),aimingto
manipulatethebehaviorof G’soutputcode.Themalicious
engineisthenconstructedbyfeedingtheadversarialpair
into G:
adv
G isassessedusingthemetricsdefinedinSection2.
adv
adv
G (p,s)= M(·|f
pre
(f
adv
(p,s))).Thesuccessof
G shouldexhibitahighvulnerabilityrate,asquantified
adv
byvul ratio(G )
inEquation(3),andmaintainstrong
functionalcorrectnessrelativetotheoriginalengine G,as
adv
measuredbyfunc rate@k(G ,
G) inEquation(2).
3.2.Attacker’sKnowledge
Here,weoutlinetheknowledgeandcapabilitiesthe
attackerhasformountingtheirattack.
Black-boxAccess Weassumethattheattackeronlyhas
black-boxqueryaccesstotheoriginalcodecompletion
engine G.Thismeansthattheattackercansubmitstring
inputsto G andreceivecorrespondingstringoutputs(fora
sufficientnumberoftimes).However,theattackerdoesnot
haveaccessto G’sarchitecture,trainingdata,parameters,
gradients,orlogits,noraretheyabletomodifyanyofthese
components.TheattackerevenhasnoaccesstoG’stokenizer.
However,theattackerisfreetouseanytokenizer T available
online.Assuch,ourthreatmodelmakesminimalassumptions
abouttheinternalsof G andcapturesabroadrangeof
importantpracticalsettings,includingattacksonblack-box
APIslikeOpenAIAPI[22]andcommercialpluginssuch
asGitHubCopilot[12].Additionally,theblack-boxaccess
eliminatestheneedfortheattackertotrainanddeploy
anLLM,whichwouldrequireexpensivecomputational
resources.
InputManipulation Weassumethattheattackeriscapable
adv
ofapplyingthefunction f tomodifytheinputstothe
originalcompletionengine G.Whilethedetailsofacquiring
suchcapabilityfalloutsidethescopeofthiswork,we
discussseveralpossiblerealisticscenarios.Inonescenario,
theattackermightsetupamaliciousserviceorplugin,
withfullcontrolovertheapplicationof
f
adv
fadv.Moreover,
mightbeusedbymodeldevelopersforred-teaming
exercises.Thedesiredmodificationsmightalsobeachievable
throughpromptinjection[2]orinterceptinguserrequeststo
completionengines.
Wenotethatalthoughtheattackermightpossesstheca-
pabilitytomodifycodethroughpost-processing,introducing
vulnerabilitiesintothegeneratedcodeinthiswayisboth
challengingandcostly[21],whichcanresultinconsiderable
overheadandreducedutilityfor Gadv.Therefore,wedonot
considerpost-processingattacksinthiswork.
KnowledgeaboutVulnerabilities Theattackerisassumed
tohaveageneralunderstandingofthetargetvulnerabilities
theyintendtointroducetotheprogrammer’scodebase.As
such,theyareabletocollectadatasetofcompletiontasks
wherethetargetvulnerabilitycouldoccurandusetoolsto
detectsuchvulnerabilities.