Hi everyone!
We’ve just published v0.3.2, the 3rd public alpha of the SoulCrafted Slicer.
This development cycle has been somewhat frustrating, we’ve put a lot of effort, and yet there isn’t “much” to show for it. Almost all the work went into the 3MF file format support. The Slicer now opens 3MF files generated by other apps that it used to refuse; while it also refuses maliciously crafted and other problematic files.
As we are approaching a whole month of development, I decided to cut a release with what we have. Sadly, I couldn’t work on all the issues that were known by the time that v0.3.1 was released, and we’ve discovered “new” issues since then.
We have a section for these known problems by the end of this article, so please read it before you print anything, to ensure that these problems don’t affect you.
3MF files from other slicers
3MF files are
ZIP archives with many files
inside. One of these files ([Content_Types].xml) is a list that tells what
kind of content the other fields hold (model, preview picture, …). Other apps
(CAD, Slicers, …) often add files of their own to the archive, with (for
example) data such as print settings, and leave them out of
[Content_Types].xml. Most versions of the 3MF specification allow doing that,
and say that programs should just ignore unlisted files.
Our Slicer wasn’t ignoring them, but rejecting the whole 3MF instead when it found these unlisted files. Now it just skips these extra files and goes on to read the model.
Sadly, that isn’t enough for every file. While the range of accepted files was noticeably expanded, we are not done yet on improving support for 3MF files. One of such roadblocks is the “Production extension”, which we don’t yet support. We’ve seen it in files saved by Bambu Studio, OrcaSlicer and Creality Print. If you get an error that mentions an “unsupported 3MF extension”, this is why.
We also covered a much rarer case. The format lets a file inside the archive be stored in several pieces, and the Slicer used to refuse those archives. Now it puts the pieces back together.
Case sensitivity was another reason for refusals. The spec mandates that, in some parts of the files, upper and lower case have to be treated as equal, and our code wasn’t following that rules thoroughly enough. Because of it, some valid files were refused, now this has been fixed as well.
Files that can be read in 2 ways
At the beginning of this post I mentioned the cases of maliciously crafted files. A subset of such cases are ZIP archives crafted in such a way that 2 different programs might understand them in completely different ways; I won’t go into how this could be used for nefarious purposes, but if you think a bit about it, you’ll likely find many possibilities. This release deals with more cases of that kind.
Some of them come from the ZIP format itself. A few weeks ago, a security advisory was published for the library we use to read ZIP archives. Inside a ZIP archive, every file is described twice, once right before its contents and once more in an index at the end of the archive. Nothing forces both descriptions to say the same thing, and some programs read one while others read the other. So a carefully built archive can show different files to different programs.
The Slicer only checked the index. For that same reason, it could have a different view of the loaded model respect to what other applications might “see”.
We’ve updated the library (twice, as its later versions fixed more problems), and we’ve also added checks of our own. The Slicer now compares both descriptions of every file in the archive, and it refuses the 3MF file if they disagree about the name, the size or almost anything else.
It also refuses archives with files that the index doesn’t mention (not to be
confused with what I mentioned earlier regarding the [Content_Types].xml list),
files that are really 2 archives glued one after the other, and archives that
claim to be split across several
disks (For those who were born after
the year 2000, that was very common when high storage capacities were still not
available for common users).
3MF had a similar problem of its own. Every 3MF file has a note that tells which of the files in the archive is the model. A file could carry 2 of those notes pointing at 2 different models, and the Slicer took the first one without saying anything. Now it refuses the file, since nothing guarantees that another program would take the same one.
That same note can also be marked as pointing outside the archive, to a web address for instance. The Slicer ignored that mark and looked for a file with that name inside the archive anyway, so it could load a model that a program following the format wouldn’t. Now it refuses those files too.
There’s still a gap here. When you import a package of profiles, the Slicer also reads a ZIP archive, and that one doesn’t go through our own checks yet.
Several revisions of the same format
There’s a less obvious reason why 2 programs can disagree about a file. The rules of 3MF have been revised several times, and so have the packaging rules that 3MF is built on (OPC, the same ones that Word and Excel documents use). The revisions don’t agree on every detail, so a file can be valid for one of them and invalid for another.
The Slicer now takes all of them into account. It reads every file by the rules of each revision, which means 5 OPC editions combined with 6 3MF versions. Roughly speaking and simplifying a bit, if at least one combination accepts the file, the Slicer opens it. But when 2 combinations accept it and interpret it in different ways, the Slicer refuses it because, at best, it’s a problematic file, and at worst, a maliciously crafted one.
Memory use blowing up
A file can also be built to make a program use far more memory than its size suggests. We found and fixed one such case in the way the Slicer handled the list of contents that we mentioned at the beginning. We estimate that a file of little more than 1 MB could be crafted in such a way that makes v0.3.1 take around 4 GB of memory. The same crafted file now only takes 13 MB.
The Slicer also checks the names of the files in the archive before it unpacks any of them. It used to unpack them all first, even when the names alone were enough to refuse the 3MF file.
More fixes in the ZIP library
Updating the ZIP library also fixed 5 other security problems of the version that v0.3.1 used. With a carefully built archive, that version could:
- miscalculate where things are inside the archive (GHSA-w2w4-j3wm-rrpp);
- spend a very long time on an archive full of fake end markers (GHSA-2vxq-ffpp-66cq, GHSA-x2cq-c87r-5mfx);
- misread the extra information that very large archives carry (GHSA-2fwm-pm8w-697g);
- list different files than other programs do (GHSA-wjr6-mhvj-cjvm). The checks of our own that we described above already catch this one.
We now require one exact version of the library, so a new version only comes in after we’ve reviewed it. The one in this release, 9.1.3, already has 6 advisories of its own, published in the last few days and fixed in newer versions. Of those, 5 are in parts of the library that the Slicer doesn’t use: unpacking archives to disk, encrypted archives, and a way of reading an archive from start to end. The 6th (GHSA-fpwh-q2m5-vfm2) says that the fix for the advisory that we talked about earlier missed a case, and we haven’t checked yet whether it affects the Slicer.
Warnings and error messages
Sometimes we find files that, while they are not compliant with the specs’ rules, do not present a risk to the applications that read them. We’ve chosen to be lenient with them to ensure broader compatibility, but warnings will be shown so the user can be aware of the problems.
Most of said warnings won’t be immediately shown to the user through the GUI,
but through the terminal (on stderr), so if you need or want to debug what’s
going on, it’s advisable to start the Slicer via command line.
Expect some of those lines with files saved by some other slicers. 3MF is notoriously hard to implement, and, for the time being, most of us have imperfect implementations for it.
The messages for refused files changed too. When the archive is damaged, the Slicer used to pass along the short text of the ZIP library, such as “Invalid checksum”, and now it explains the problem in its own words. For the other refusals, the messages used to give a single reason, and now they tell what each revision of the format found wrong with the file. That makes them long and quite technical. Still, if the Slicer refuses a file that you think is fine, that message is what we need to find out why, so please copy it into the reports you send to us.
Printer pictures
We found that png (what we use to decode PNG
images) crashes with some malformed files. For the Slicer this had a small but
annoying consequence: If just one of the printer pictures was damaged in that
way, then all the printers in the Preferences were left without their picture.
The library authors had already fixed those crashes, but the fixes aren’t
published yet. Until they are, we build the Slicer with a vendored patched
version of png, maintained in our repository.
We also fixed the Slicer itself, so when a picture can’t be loaded, that won’t affect the others.
Translations
Since the last release, the translations into Ukrainian, Spanish, French and Dutch have grown a lot (the French one started from scratch).
Thanks to @gallegonovato, @aspimaker, @SomeTR, @Augustin_Martignoni, @Veetalin, and @dakkafex for yor work on the translations!
If you speak many languages and have some spare time, we’d love your help, and you don’t need to know how to code. To those who are already translating the Slicer, thank you once more!
Under the hood
Like last time, part of the work won’t show on your screen.
The 3MF Consortium, the group that maintains the format, publishes a large collection of test files. For each file, it says whether a program must open it or must refuse it. Most of the collection tests the optional extensions of the format (programs that doesn’t support an extension must refuse the files that require it).
Up to v0.3.1, our automatic tests used only 6 files published by the Consortium, and the code that reads 3MF files had 305 tests. Now our tests check 699 of the Consortium’s files, each one against the result that we expect from the Slicer, and that same code has 990 tests.
We also ran the whole collection, 2271 files, through the Slicer, and none of them made it crash. It opened all the valid files of the suite that covers the core of the format. In the rest of the collection, it refused almost all the valid files. Most of them require an extension that the Slicer doesn’t support, and in that case the format asks for that refusal. The new checks on the ZIP archive and the packaging didn’t refuse any of the valid files.
The other valid files that the Slicer refused use the slice extension, which it supports only in part. They give the real shape of a model only through its slices, and add a rough mesh as a preview. The Slicer can’t load a model from its slices yet, and slicing that rough mesh would give the wrong shape, so it refused them.
Of the 552 files that break the rules, the Slicer refused 521 and opened the other 31:
- 7 on purpose, because their fault leaves no doubt about what’s inside them. They’re the kind of file that we chose to be lenient with to broaden compatibility.
- 1 that it should also open on purpose, but that still lacks the proper associated warning messages.
- 4 that it must refuse. The changes that will make it refuse them are already planned.
- 19 that we still have to study one by one, to decide what the Slicer should do with each of them.
If you build the Slicer from its source code, keep in mind that you now have to download those files once before running the tests (about 310 MB). The contributing guide explains how.
To make all of this possible, we rewrote most of the code that reads 3MF files, so that each revision of the format is handled on its own.
We also made the automatic checks on our own code stricter. The older code that doesn’t pass yet the new automated checks is marked, and we fix it whenever we touch it.
Published libraries
Most of the Slicer is made of libraries, pieces of code that each do one job, such as reading 3MF files, slicing a model or writing the files for the printer. Rust programmers share their libraries on crates.io. We hadn’t published ours there since July, so the published versions lacked months of work, including everything in this article about 3MF files.
We’ve now published new versions of 13 of them (2 are there for the first time). If you program in Rust, you can build on any of them, and if you do, we’d love to hear about it.
Known issues
Besides what we’ve already mentioned, there are 2 problems that we know about and that this release doesn’t fix.
- A flat horizontal face of a model (sometimes) can make a layer come out empty or incomplete, without any warning. It happens when the face lies exactly at the height where the Slicer samples a layer, which is the middle of that layer. With 0.05 mm layers, for example, that’s the case for a face 3.175 mm (1/8 inch) above the build plate. In other cases the slicing stops with an error about “non-manifold geometry”, even though the model is fine. This bug has been there since v0.3.0.
- On Linux, with GNOME on Wayland and an NVIDIA graphics card, the window of the Slicer can stop updating after it has been idle or hidden for a long time. The Slicer keeps running underneath, and the window comes back by itself, but that can take as long as the time it was idle. Closing the Slicer and opening it again works too. What we’ve measured points at NVIDIA’s driver, and other programs have the same problem. We haven’t decided yet what to do about it on our side.
Trying it out
As always, you can download it from our main page or from its release page on Codeberg.
Keep in mind that the Slicer is still in alpha. We advise to try it with small models first, so you won’t waste much time and/or resin if something goes wrong.
If you find a bug, or a 3MF file that the Slicer refuses and you think it shouldn’t, please tell us in our issue tracker.
Thank you for reading, and happy printing!